summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
committerBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
commitc56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7 (patch)
tree5cb64dfe155e5d2349efb6c7dc4b0f5b5284d44a
parentFix Windows php build to restore nuget packages (diff)
downloadice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.bz2
ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.xz
ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.zip
Refactored SSL and iAP transports, support for running SSL on top
of TCP/iAP/Bluetooth.
-rw-r--r--CHANGELOG-3.7.md19
-rw-r--r--config/Make.project.rules7
-rw-r--r--config/Make.rules.Darwin16
-rw-r--r--config/Make.rules.Linux4
-rw-r--r--config/iphoneos-SDKSettings.plist4
-rw-r--r--config/iphonesimulator-SDKSettings.plist4
-rw-r--r--config/macosx-SDKSettings.plist4
-rwxr-xr-xcpp/allTests.py2
-rw-r--r--cpp/config/Make.xcodesdk.rules2
-rw-r--r--cpp/include/Ice/MetricsObserverI.h40
-rw-r--r--cpp/include/Ice/RegisterPlugins.h9
-rw-r--r--cpp/include/IceIAP/IceIAP.h (renamed from java/src/Ice/src/main/java/IceInternal/WSEndpointDelegate.java)17
-rw-r--r--cpp/include/IceSSL/Config.h9
-rw-r--r--cpp/include/IceSSL/IceSSL.h2
-rw-r--r--cpp/include/IceSSL/Plugin.h79
-rw-r--r--cpp/msbuild/ice.proj2
-rw-r--r--cpp/src/Glacier2/SessionRouterI.cpp27
-rw-r--r--cpp/src/Ice/ConnectionI.cpp12
-rw-r--r--cpp/src/Ice/EndpointFactory.h2
-rw-r--r--cpp/src/Ice/EndpointI.cpp9
-rw-r--r--cpp/src/Ice/EndpointI.h5
-rw-r--r--cpp/src/Ice/IPEndpointI.cpp26
-rw-r--r--cpp/src/Ice/IPEndpointI.h6
-rw-r--r--cpp/src/Ice/Incoming.cpp22
-rw-r--r--cpp/src/Ice/Instance.cpp12
-rw-r--r--cpp/src/Ice/InstrumentationI.cpp16
-rw-r--r--cpp/src/Ice/Makefile.mk2
-rwxr-xr-x[-rw-r--r--]cpp/src/Ice/Network.cpp112
-rwxr-xr-x[-rw-r--r--]cpp/src/Ice/Network.h15
-rw-r--r--cpp/src/Ice/OpaqueEndpointI.cpp8
-rw-r--r--cpp/src/Ice/OpaqueEndpointI.h1
-rw-r--r--cpp/src/Ice/Selector.cpp4
-rwxr-xr-x[-rw-r--r--]cpp/src/Ice/StreamSocket.cpp197
-rw-r--r--cpp/src/Ice/StreamSocket.h14
-rwxr-xr-x[-rw-r--r--]cpp/src/Ice/TcpAcceptor.cpp172
-rw-r--r--cpp/src/Ice/TcpAcceptor.h14
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp26
-rw-r--r--cpp/src/Ice/TcpEndpointI.h10
-rw-r--r--cpp/src/Ice/TcpTransceiver.cpp29
-rw-r--r--cpp/src/Ice/TcpTransceiver.h8
-rw-r--r--cpp/src/Ice/UdpEndpointI.cpp32
-rw-r--r--cpp/src/Ice/UdpEndpointI.h7
-rwxr-xr-x[-rw-r--r--]cpp/src/Ice/UdpTransceiver.cpp134
-rw-r--r--cpp/src/Ice/UdpTransceiver.h10
-rw-r--r--cpp/src/Ice/WSAcceptor.cpp8
-rw-r--r--cpp/src/Ice/WSAcceptor.h6
-rw-r--r--cpp/src/Ice/WSConnector.cpp8
-rw-r--r--cpp/src/Ice/WSConnector.h5
-rw-r--r--cpp/src/Ice/WSEndpoint.cpp80
-rw-r--r--cpp/src/Ice/WSEndpoint.h19
-rw-r--r--cpp/src/Ice/WSTransceiver.cpp20
-rw-r--r--cpp/src/Ice/WSTransceiver.h18
-rw-r--r--cpp/src/Ice/ios/RegisterPluginsInit.cpp30
-rw-r--r--cpp/src/Ice/ios/StreamEndpointI.cpp352
-rw-r--r--cpp/src/Ice/ios/StreamEndpointI.h23
-rw-r--r--cpp/src/Ice/ios/StreamTransceiver.cpp210
-rw-r--r--cpp/src/Ice/ios/StreamTransceiver.h10
-rw-r--r--cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj13
-rw-r--r--cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj.filters29
-rw-r--r--cpp/src/Ice/uwp/RegisterPluginsInit.cpp46
-rw-r--r--cpp/src/Ice/uwp/TcpAcceptor.cpp221
-rw-r--r--cpp/src/Ice/uwp/TcpAcceptor.h65
-rw-r--r--cpp/src/Ice/uwp/TcpConnector.cpp126
-rw-r--r--cpp/src/Ice/uwp/TcpConnector.h47
-rw-r--r--cpp/src/Ice/uwp/TcpEndpointI.cpp426
-rw-r--r--cpp/src/Ice/uwp/TcpEndpointI.h100
-rw-r--r--cpp/src/Ice/uwp/TcpTransceiver.cpp399
-rw-r--r--cpp/src/Ice/uwp/TcpTransceiver.h94
-rw-r--r--cpp/src/Ice/uwp/TransceiverF.h31
-rw-r--r--cpp/src/IceBT/EndpointI.cpp7
-rw-r--r--cpp/src/IceBT/EndpointI.h7
-rw-r--r--cpp/src/IceBT/PluginI.cpp12
-rw-r--r--cpp/src/IceBT/StreamSocket.cpp8
-rw-r--r--cpp/src/IceBT/TransceiverI.cpp5
-rw-r--r--cpp/src/IceDiscovery/PluginI.cpp16
-rw-r--r--cpp/src/IceGrid/RegistryI.cpp22
-rw-r--r--cpp/src/IceIAP/Connector.h (renamed from cpp/src/Ice/ios/iAPConnector.h)0
-rw-r--r--cpp/src/IceIAP/Connector.mm (renamed from cpp/src/Ice/ios/iAPConnector.mm)6
-rw-r--r--cpp/src/IceIAP/EndpointI.h (renamed from cpp/src/Ice/ios/iAPEndpointI.h)5
-rw-r--r--cpp/src/IceIAP/EndpointI.mm (renamed from cpp/src/Ice/ios/iAPEndpointI.mm)114
-rw-r--r--cpp/src/IceIAP/Makefile.mk20
-rw-r--r--cpp/src/IceIAP/Transceiver.h (renamed from cpp/src/Ice/ios/iAPTransceiver.h)1
-rw-r--r--cpp/src/IceIAP/Transceiver.mm (renamed from cpp/src/Ice/ios/iAPTransceiver.mm)73
-rw-r--r--cpp/src/IceLocatorDiscovery/PluginI.cpp16
-rw-r--r--cpp/src/IcePatch2/Server.cpp6
-rw-r--r--cpp/src/IceSSL/AcceptorI.cpp178
-rw-r--r--cpp/src/IceSSL/AcceptorI.h17
-rwxr-xr-x[-rw-r--r--]cpp/src/IceSSL/Certificate.cpp606
-rw-r--r--cpp/src/IceSSL/ConnectorI.cpp58
-rw-r--r--cpp/src/IceSSL/ConnectorI.h10
-rw-r--r--cpp/src/IceSSL/EndpointI.cpp327
-rw-r--r--cpp/src/IceSSL/EndpointI.h43
-rw-r--r--cpp/src/IceSSL/Instance.cpp5
-rw-r--r--cpp/src/IceSSL/Instance.h6
-rw-r--r--cpp/src/IceSSL/Makefile.mk7
-rw-r--r--cpp/src/IceSSL/OpenSSLTransceiverI.cpp103
-rw-r--r--cpp/src/IceSSL/OpenSSLTransceiverI.h10
-rwxr-xr-x[-rw-r--r--]cpp/src/IceSSL/PluginI.cpp46
-rw-r--r--cpp/src/IceSSL/PluginI.h2
-rw-r--r--cpp/src/IceSSL/RFC2253.cpp6
-rw-r--r--cpp/src/IceSSL/SChannelTransceiverI.cpp174
-rw-r--r--cpp/src/IceSSL/SChannelTransceiverI.h10
-rw-r--r--cpp/src/IceSSL/SSLEngine.cpp18
-rw-r--r--cpp/src/IceSSL/SSLEngine.h24
-rw-r--r--cpp/src/IceSSL/SSLEngineF.h12
-rw-r--r--cpp/src/IceSSL/SecureTransportEngine.cpp145
-rw-r--r--cpp/src/IceSSL/SecureTransportTransceiverI.cpp170
-rw-r--r--cpp/src/IceSSL/SecureTransportTransceiverI.h13
-rw-r--r--cpp/src/IceSSL/TrustManager.cpp15
-rw-r--r--cpp/src/IceSSL/TrustManager.h2
-rwxr-xr-x[-rw-r--r--]cpp/src/IceSSL/Util.cpp445
-rw-r--r--cpp/src/IceSSL/Util.h14
-rwxr-xr-xcpp/src/IceSSL/WinRTEngine.cpp43
-rwxr-xr-xcpp/src/IceSSL/WinRTTransceiverI.cpp199
-rwxr-xr-xcpp/src/IceSSL/WinRTTransceiverI.h81
-rw-r--r--cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj16
-rw-r--r--cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj.filters46
-rw-r--r--cpp/src/slice2cpp/Gen.cpp2
-rw-r--r--cpp/test/Ice/background/EndpointFactory.cpp2
-rw-r--r--cpp/test/Ice/background/EndpointFactory.h3
-rw-r--r--cpp/test/Ice/background/EndpointI.cpp4
-rw-r--r--cpp/test/Ice/background/EndpointI.h4
-rw-r--r--cpp/test/Ice/info/AllTests.cpp98
-rw-r--r--cpp/test/Ice/info/TestI.cpp48
-rw-r--r--cpp/test/Ice/metrics/AllTests.cpp54
-rw-r--r--cpp/test/Ice/metrics/Client.cpp2
-rw-r--r--cpp/test/Ice/networkProxy/AllTests.cpp21
-rw-r--r--cpp/test/Ice/operations/Client.cpp5
-rw-r--r--cpp/test/Ice/slicing/exceptions/AllTests.cpp27
-rw-r--r--cpp/test/IceSSL/configuration/AllTests.cpp154
-rw-r--r--cpp/test/IceSSL/configuration/Client.cpp37
-rw-r--r--cpp/test/IceSSL/configuration/Makefile.mk4
-rw-r--r--cpp/test/IceSSL/configuration/Server.cpp7
-rw-r--r--cpp/test/IceSSL/configuration/TestI.cpp3
-rwxr-xr-xcpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj10
-rw-r--r--cpp/test/ios/Classes/AppDelegate.mm1
-rw-r--r--cpp/test/uwp/MainPage.xaml.cpp1
-rwxr-xr-xcsharp/allTests.py2
-rw-r--r--csharp/src/Ice/ConnectionI.cs9
-rw-r--r--csharp/src/Ice/EndpointFactory.cs2
-rw-r--r--csharp/src/Ice/EndpointI.cs8
-rw-r--r--csharp/src/Ice/IPEndpointI.cs19
-rw-r--r--csharp/src/Ice/Incoming.cs8
-rw-r--r--csharp/src/Ice/Instance.cs4
-rw-r--r--csharp/src/Ice/InstrumentationI.cs153
-rw-r--r--csharp/src/Ice/MetricsObserverI.cs89
-rw-r--r--csharp/src/Ice/OpaqueEndpointI.cs8
-rw-r--r--csharp/src/Ice/TcpEndpointI.cs49
-rw-r--r--csharp/src/Ice/TcpTransceiver.cs37
-rw-r--r--csharp/src/Ice/UdpEndpointI.cs2
-rw-r--r--csharp/src/Ice/WSConnector.cs6
-rw-r--r--csharp/src/Ice/WSEndpoint.cs67
-rw-r--r--csharp/src/Ice/WSTransceiver.cs24
-rw-r--r--csharp/src/IceSSL/AcceptorI.cs134
-rw-r--r--csharp/src/IceSSL/ConnectorI.cs51
-rw-r--r--csharp/src/IceSSL/EndpointI.cs343
-rw-r--r--csharp/src/IceSSL/Instance.cs4
-rw-r--r--csharp/src/IceSSL/PluginI.cs12
-rw-r--r--csharp/src/IceSSL/SSLEngine.cs11
-rw-r--r--csharp/src/IceSSL/TransceiverI.cs199
-rw-r--r--csharp/src/IceSSL/TrustManager.cs11
-rw-r--r--csharp/src/IceSSL/Util.cs14
-rw-r--r--csharp/test/Ice/background/EndpointFactory.cs2
-rw-r--r--csharp/test/Ice/background/EndpointI.cs4
-rw-r--r--csharp/test/Ice/info/AllTests.cs142
-rw-r--r--csharp/test/Ice/info/TestI.cs37
-rw-r--r--csharp/test/Ice/metrics/AllTests.cs52
-rw-r--r--csharp/test/Ice/networkProxy/AllTests.cs14
-rw-r--r--csharp/test/IceSSL/configuration/AllTests.cs4
-rw-r--r--csharp/test/IceSSL/configuration/TestI.cs2
-rwxr-xr-xjava/allTests.py2
-rw-r--r--java/src/Ice/src/main/java/Ice/ConnectionI.java9
-rw-r--r--java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java171
-rw-r--r--java/src/Ice/src/main/java/IceInternal/EndpointFactory.java2
-rw-r--r--java/src/Ice/src/main/java/IceInternal/EndpointI.java9
-rw-r--r--java/src/Ice/src/main/java/IceInternal/IPEndpointI.java21
-rw-r--r--java/src/Ice/src/main/java/IceInternal/IncomingBase.java11
-rw-r--r--java/src/Ice/src/main/java/IceInternal/Instance.java4
-rw-r--r--java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java38
-rw-r--r--java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java2
-rw-r--r--java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java41
-rw-r--r--java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java48
-rw-r--r--java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java2
-rw-r--r--java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java33
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSConnector.java6
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSEndpoint.java48
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java15
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSTransceiver.java14
-rw-r--r--java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java19
-rw-r--r--java/src/Ice/src/main/java/IceMX/MetricsHelper.java43
-rw-r--r--java/src/Ice/src/main/java/IceSSL/AcceptorI.java112
-rw-r--r--java/src/Ice/src/main/java/IceSSL/ConnectorI.java61
-rw-r--r--java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java16
-rw-r--r--java/src/Ice/src/main/java/IceSSL/EndpointI.java326
-rw-r--r--java/src/Ice/src/main/java/IceSSL/Instance.java12
-rw-r--r--java/src/Ice/src/main/java/IceSSL/PluginI.java18
-rw-r--r--java/src/Ice/src/main/java/IceSSL/SSLEngine.java23
-rw-r--r--java/src/Ice/src/main/java/IceSSL/TransceiverI.java272
-rw-r--r--java/src/Ice/src/main/java/IceSSL/TrustManager.java9
-rw-r--r--java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java27
-rw-r--r--java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java4
-rw-r--r--java/src/IceBT/src/main/java/IceBT/EndpointI.java4
-rw-r--r--java/src/IceBT/src/main/java/IceBT/PluginI.java2
-rw-r--r--java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java45
-rw-r--r--java/test/src/main/java/test/Ice/background/EndpointFactory.java2
-rw-r--r--java/test/src/main/java/test/Ice/background/EndpointI.java4
-rw-r--r--java/test/src/main/java/test/Ice/info/AllTests.java122
-rw-r--r--java/test/src/main/java/test/Ice/info/TestI.java39
-rw-r--r--java/test/src/main/java/test/Ice/metrics/AllTests.java55
-rw-r--r--java/test/src/main/java/test/Ice/networkProxy/AllTests.java9
-rw-r--r--java/test/src/main/java/test/IceSSL/configuration/AllTests.java6
-rw-r--r--js/Makefile5
-rw-r--r--js/src/Ice/ConnectionI.js7
-rw-r--r--js/src/Ice/IncomingAsync.js9
-rw-r--r--js/src/Ice/Instance.js2
-rw-r--r--js/src/Ice/OpaqueEndpointI.js2
-rw-r--r--js/src/Ice/TcpEndpointI.js4
-rw-r--r--js/src/Ice/WSEndpoint.js6
-rw-r--r--js/src/Ice/browser/WSTransceiver.js16
-rw-r--r--js/test/Ice/info/Client.js43
-rw-r--r--js/test/Ice/optional/Client.js1
-rw-r--r--objective-c/config/Make.rules6
-rw-r--r--objective-c/include/objc/Ice/Initialize.h7
-rw-r--r--objective-c/src/Ice/ConnectionI.h13
-rw-r--r--objective-c/src/Ice/ConnectionI.mm133
-rw-r--r--objective-c/src/Ice/EndpointI.h8
-rw-r--r--objective-c/src/Ice/EndpointI.mm159
-rw-r--r--objective-c/src/Ice/Initialize.mm16
-rw-r--r--objective-c/src/Ice/LocalObject.mm36
-rw-r--r--objective-c/src/Ice/LocalObjectI.h2
-rw-r--r--objective-c/src/IceSSL/ConnectionInfoI.mm59
-rw-r--r--objective-c/src/IceSSL/EndpointInfoI.mm62
-rw-r--r--objective-c/test/Ice/acm/Client.m7
-rw-r--r--objective-c/test/Ice/acm/Server.m7
-rw-r--r--objective-c/test/Ice/adapterDeactivation/Client.m9
-rw-r--r--objective-c/test/Ice/adapterDeactivation/Collocated.m7
-rw-r--r--objective-c/test/Ice/adapterDeactivation/Server.m9
-rw-r--r--objective-c/test/Ice/admin/Client.m9
-rw-r--r--objective-c/test/Ice/admin/Server.m9
-rw-r--r--objective-c/test/Ice/ami/Client.m7
-rw-r--r--objective-c/test/Ice/ami/Collocated.m7
-rw-r--r--objective-c/test/Ice/ami/Server.m13
-rw-r--r--objective-c/test/Ice/binding/Client.m9
-rw-r--r--objective-c/test/Ice/binding/Server.m9
-rw-r--r--objective-c/test/Ice/defaultServant/Client.m7
-rw-r--r--objective-c/test/Ice/defaultValue/Client.m7
-rw-r--r--objective-c/test/Ice/dispatcher/Client.m9
-rw-r--r--objective-c/test/Ice/dispatcher/Collocated.m7
-rw-r--r--objective-c/test/Ice/dispatcher/Server.m7
-rw-r--r--objective-c/test/Ice/enums/Client.m7
-rw-r--r--objective-c/test/Ice/enums/Server.m7
-rw-r--r--objective-c/test/Ice/exceptions/Client.m7
-rw-r--r--objective-c/test/Ice/exceptions/Collocated.m7
-rw-r--r--objective-c/test/Ice/exceptions/Server.m7
-rw-r--r--objective-c/test/Ice/facets/Client.m7
-rw-r--r--objective-c/test/Ice/facets/Collocated.m7
-rw-r--r--objective-c/test/Ice/facets/Server.m7
-rw-r--r--objective-c/test/Ice/faultTolerance/Client.m7
-rw-r--r--objective-c/test/Ice/faultTolerance/Server.m7
-rw-r--r--objective-c/test/Ice/hash/Client.m7
-rw-r--r--objective-c/test/Ice/hold/Client.m9
-rw-r--r--objective-c/test/Ice/hold/Server.m23
-rw-r--r--objective-c/test/Ice/info/AllTests.m118
-rw-r--r--objective-c/test/Ice/info/Client.m7
-rw-r--r--objective-c/test/Ice/info/Server.m7
-rw-r--r--objective-c/test/Ice/info/TestI.m39
-rw-r--r--objective-c/test/Ice/inheritance/Client.m7
-rw-r--r--objective-c/test/Ice/inheritance/Collocated.m7
-rw-r--r--objective-c/test/Ice/inheritance/Server.m7
-rw-r--r--objective-c/test/Ice/interceptor/Client.m8
-rw-r--r--objective-c/test/Ice/invoke/Client.m7
-rw-r--r--objective-c/test/Ice/invoke/Server.m7
-rw-r--r--objective-c/test/Ice/location/Client.m7
-rw-r--r--objective-c/test/Ice/location/Server.m7
-rw-r--r--objective-c/test/Ice/metrics/Client.m7
-rw-r--r--objective-c/test/Ice/metrics/Server.m7
-rw-r--r--objective-c/test/Ice/objects/Client.m7
-rw-r--r--objective-c/test/Ice/objects/Collocated.m7
-rw-r--r--objective-c/test/Ice/objects/Server.m7
-rw-r--r--objective-c/test/Ice/operations/Client.m7
-rw-r--r--objective-c/test/Ice/operations/Collocated.m7
-rw-r--r--objective-c/test/Ice/operations/Server.m7
-rw-r--r--objective-c/test/Ice/optional/Client.m7
-rw-r--r--objective-c/test/Ice/optional/Server.m7
-rw-r--r--objective-c/test/Ice/proxy/Client.m7
-rw-r--r--objective-c/test/Ice/proxy/Collocated.m7
-rw-r--r--objective-c/test/Ice/proxy/Server.m7
-rw-r--r--objective-c/test/Ice/retry/Client.m7
-rw-r--r--objective-c/test/Ice/retry/Collocated.m7
-rw-r--r--objective-c/test/Ice/retry/Server.m7
-rw-r--r--objective-c/test/Ice/servantLocator/Client.m7
-rw-r--r--objective-c/test/Ice/servantLocator/Collocated.m7
-rw-r--r--objective-c/test/Ice/servantLocator/Server.m7
-rw-r--r--objective-c/test/Ice/services/Client.m7
-rw-r--r--objective-c/test/Ice/slicing/exceptions/Client.m11
-rw-r--r--objective-c/test/Ice/slicing/exceptions/Server.m7
-rw-r--r--objective-c/test/Ice/slicing/objects/Client.m7
-rw-r--r--objective-c/test/Ice/slicing/objects/Server.m7
-rw-r--r--objective-c/test/Ice/stream/Client.m7
-rw-r--r--objective-c/test/Ice/timeout/Client.m7
-rw-r--r--objective-c/test/Ice/timeout/Server.m7
-rw-r--r--objective-c/test/Slice/keyword/Client.m5
-rwxr-xr-xobjective-c/test/ios/Objective-C Test Suite.xcodeproj/project.pbxproj4
-rw-r--r--php/src/php5/Connection.cpp63
-rw-r--r--php/src/php5/Endpoint.cpp43
-rw-r--r--php/src/php7/Connection.cpp60
-rw-r--r--php/src/php7/Endpoint.cpp40
-rw-r--r--php/test/Ice/info/Client.php101
-rw-r--r--python/modules/IcePy/ConnectionInfo.cpp189
-rw-r--r--python/modules/IcePy/EndpointInfo.cpp104
-rw-r--r--python/python/Ice.py4
-rw-r--r--python/test/Ice/info/AllTests.py99
-rw-r--r--python/test/Ice/info/TestI.py25
-rw-r--r--ruby/src/IceRuby/Connection.cpp79
-rw-r--r--ruby/src/IceRuby/Endpoint.cpp58
-rw-r--r--ruby/test/Ice/info/AllTests.rb85
-rw-r--r--slice/Ice/Connection.ice63
-rw-r--r--slice/Ice/Endpoint.ice28
-rw-r--r--slice/IceBT/ConnectionInfo.ice6
-rw-r--r--slice/IceBT/EndpointInfo.ice9
-rw-r--r--slice/IceIAP/ConnectionInfo.ice71
-rw-r--r--slice/IceIAP/EndpointInfo.ice65
-rw-r--r--slice/IceSSL/ConnectionInfo.ice13
-rw-r--r--slice/IceSSL/EndpointInfo.ice26
324 files changed, 6206 insertions, 6722 deletions
diff --git a/CHANGELOG-3.7.md b/CHANGELOG-3.7.md
index 459d76c32c9..2298ed15b29 100644
--- a/CHANGELOG-3.7.md
+++ b/CHANGELOG-3.7.md
@@ -17,6 +17,25 @@ These are the changes since Ice 3.6.2.
## General Changes
+- The iOS SSL transport is now based on the same implementation as macOS. Most
+ of the functionality supported on macOS is now also supported on iOS. There
+ are still few limitations however:
+
+ - the `checkValidity`, `getNotBefore`, `getNotAfter` methods are not supported
+ on the `IceSSL::Certificate` class.
+
+ - only PKCS12 certificates are supported (no support for PEM).
+
+- Added support for iAP transport to allow iOS clients to communicate with
+ connected accessories.
+
+- The `Ice::ConnectionInfo` `sndSize` and `rcvSize` data members have been moved
+ to the TCP and UDP connection info classes. The `Ice::WSEndpointInfo` and
+ `IceSSL::EndpointInfo` classes no longer inherit `Ice::IPConnectionInfo` and
+ instead directly extend `Ice::ConnectionInfo`. IP connection information can
+ still be retrieved by accessing the connection information object stored with
+ the new `underlying` data member.
+
- IceGrid and IceStorm now use LMDB for their persistent storage instead of
Freeze/BerkeleyDB.
diff --git a/config/Make.project.rules b/config/Make.project.rules
index 87b48c9c48c..93bbdf79e93 100644
--- a/config/Make.project.rules
+++ b/config/Make.project.rules
@@ -166,7 +166,7 @@ endif
$3/%.h $2/%.$($6_targetext): $1/%.ice $($6_path) | $3
$(E) "Compiling $$<"
$(Q)$(RM) $3/$$*.h $2/$$*.$($6_targetext)
- $(Q)$($6_path) $(strip $5) --depend $$< > $2/$$*.ice.d
+ $(Q)$($6_path) $(strip $5) --depend $$< | sed 's|\(.*:\)|$3/$$*.h $2/$$*.$($6_targetext):|' > $2/$$*.ice.d
$(Q)$($6_path) $(strip $5) --output-dir $2 $$<
$(if $(filter-out $2,$3),$(Q)$(MV) $2/$$*.h $3/)
@@ -375,8 +375,8 @@ $2_project := $1
$2_target := $$(call var-with-default,$2_target,$3)
$2_targetname := $$(call var-with-default,$2_targetname,$(patsubst $1_%,%,$2))
-$2_platforms := $$(call unique,$$(or $$($2_platforms),$$($1_platforms),$(call component-platforms,$1,$2)))
-$2_configs := $$(call unique,$$(or $$($2_configs),$$($1_configs),$(call component-configs,$1,$2)))
+$2_platforms := $$(filter $(platforms),$$(call unique,$$(or $$($2_platforms),$$($1_platforms),$(call component-platforms,$1,$2))))
+$2_configs := $$(filter $(configs),$$(call unique,$$(or $$($2_configs),$$($1_configs),$(call component-configs,$1,$2))))
#
# The installation directory (install_bindir if program, install_libdir otherwise)
@@ -801,6 +801,7 @@ $1_targetdir := $(call bindir,$1)
#
$1_configs := static
$1_platforms := $(build-platform)
+$(notdir $1)_always_enable_configs := static
#
# Defines the target extension and path of the slice translator
diff --git a/config/Make.rules.Darwin b/config/Make.rules.Darwin
index 650b9941e56..b8833877533 100644
--- a/config/Make.rules.Darwin
+++ b/config/Make.rules.Darwin
@@ -32,9 +32,9 @@ iphonesimulator_configs = %xcodesdk
iphonesimulator_targetdir = $(if $(filter %/build,$5),/iphonesimulator)
# If building objects for a shared library, enable fPIC
-shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC)
+shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC) -fvisibility=hidden
-CXXFLAGS += -fvisibility=hidden -Wall -Werror -pthread
+CXXFLAGS += -Wall -Werror -pthread
ifeq ($(MAXWARN),yes)
CXXFLAGS += -Wextra -Wshadow -Wredundant-decls
@@ -79,10 +79,18 @@ mkphpmodulename = $1.so
#
Ice_system_libs := -ldl
+# Frameworks for macos
IceSSL[macosx]_system_libs := -framework Security -framework CoreFoundation
-IceSSL[iphoneos]_system_libs := -framework ExternalAccessory \
- -framework UIKit -framework CFNetwork -framework Security -framework Foundation
+
+# Frameworks requires for iphoneos
+Ice[iphoneos]_system_libs := -framework CFNetwork -framework UIKit -framework Foundation
+IceSSL[iphoneos]_system_libs := -framework Security
+IceIAP[iphoneos]_system_libs := -framework ExternalAccessory
+
+# Same frameworks as iphoneos for iphonesimulator
+Ice[iphonesimulator]_system_libs := $(Ice[iphoneos]_system_libs)
IceSSL[iphonesimulator]_system_libs := $(IceSSL[iphoneos]_system_libs)
+IceIAP[iphonesimulator]_system_libs := $(IceIAP[iphoneos]_system_libs)
Glacier2CryptPermissionsVerifier[macosx]_system_libs := $(IceSSL[macosx]_system_libs)
Glacier2CryptPermissionsVerifier[iphoneos]_system_libs := $(IceSSL[iphoneos]_system_libs)
diff --git a/config/Make.rules.Linux b/config/Make.rules.Linux
index 77d4249bab6..265db9a1e2e 100644
--- a/config/Make.rules.Linux
+++ b/config/Make.rules.Linux
@@ -77,9 +77,9 @@ x86_targetdir = $(if $(filter %/build,$5),/x86)
endif
# If building objects for a shared library, enable fPIC
-shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC)
+shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC) -fvisibility=hidden
-CXXFLAGS += -fvisibility=hidden -Wall -Werror -pthread
+CXXFLAGS += -Wall -Werror -pthread
LDFLAGS += -pthread
ifeq ($(MAXWARN),yes)
diff --git a/config/iphoneos-SDKSettings.plist b/config/iphoneos-SDKSettings.plist
index c5c41e4faee..49068bf647d 100644
--- a/config/iphoneos-SDKSettings.plist
+++ b/config/iphoneos-SDKSettings.plist
@@ -10,6 +10,10 @@
<dict/>
<key>DefaultProperties</key>
<dict>
+ <key>GCC_PREPROCESSOR_DEFINITIONS</key>
+ <array>
+ <string>ICE_STATIC_LIBS</string>
+ </array>
<key>IPHONEOS_DEPLOYMENT_TARGET</key>
<string>7.1</string>
<key>MACOSX_DEPLOYMENT_TARGET</key>
diff --git a/config/iphonesimulator-SDKSettings.plist b/config/iphonesimulator-SDKSettings.plist
index 00db9ebcd99..e7636eefc4a 100644
--- a/config/iphonesimulator-SDKSettings.plist
+++ b/config/iphonesimulator-SDKSettings.plist
@@ -12,6 +12,10 @@
<dict>
<key>PLATFORM_NAME</key>
<string>iPhoneSimulator</string>
+ <key>GCC_PREPROCESSOR_DEFINITIONS</key>
+ <array>
+ <string>ICE_STATIC_LIBS</string>
+ </array>
</dict>
<key>DisplayName</key>
<string>Ice SDK 3.7.0</string>
diff --git a/config/macosx-SDKSettings.plist b/config/macosx-SDKSettings.plist
index c8af74780fb..912ad912e85 100644
--- a/config/macosx-SDKSettings.plist
+++ b/config/macosx-SDKSettings.plist
@@ -10,6 +10,10 @@
<string>10.9</string>
<key>PLATFORM_NAME</key>
<string>macosx</string>
+ <key>GCC_PREPROCESSOR_DEFINITIONS</key>
+ <array>
+ <string>ICE_STATIC_LIBS</string>
+ </array>
</dict>
<key>DisplayName</key>
<string>Ice SDK 3.7.0</string>
diff --git a/cpp/allTests.py b/cpp/allTests.py
index 933d634552c..619e67c5427 100755
--- a/cpp/allTests.py
+++ b/cpp/allTests.py
@@ -74,7 +74,7 @@ tests = [
("Ice/plugin", ["core", "nomingw"]),
("Ice/hash", ["once"]),
("Ice/admin", ["core", "noipv6"]),
- ("Ice/metrics", ["core", "nossl", "nows", "noipv6", "nocompress", "nomingw", "nosocks"]),
+ ("Ice/metrics", ["core", "nows", "noipv6", "nocompress", "nomingw", "nosocks"]),
("Ice/enums", ["once", "bt"]),
("Ice/logger", ["once"]),
("Ice/networkProxy", ["core", "noipv6", "nosocks"]),
diff --git a/cpp/config/Make.xcodesdk.rules b/cpp/config/Make.xcodesdk.rules
index 11fb34bdef3..097b1249f9e 100644
--- a/cpp/config/Make.xcodesdk.rules
+++ b/cpp/config/Make.xcodesdk.rules
@@ -21,7 +21,7 @@ xcodesdk_installdir = $(if $(filter %/build,$5),xcodesdk,$(if $(is-iostest-progr
xcodesdk_targetrule = $(if $(is-iostest-program),iostest,$(if $(filter-out program,$($1_target)),static))
xcodesdk_components = Ice IceSSL Glacier2 IceStorm IceGrid IceDiscovery IceLocatorDiscovery TestCommon
-xcodesdk_projects = test/Ice/% test/IceDiscovery/simple
+xcodesdk_projects = test/Ice/% test/IceDiscovery/simple test/IceSSL/configuration
xcodesdk_excludes = $(addprefix test/Ice/,background \
faultTolerance \
gc \
diff --git a/cpp/include/Ice/MetricsObserverI.h b/cpp/include/Ice/MetricsObserverI.h
index 78237a96eac..39b1f08f61b 100644
--- a/cpp/include/Ice/MetricsObserverI.h
+++ b/cpp/include/Ice/MetricsObserverI.h
@@ -183,7 +183,7 @@ protected:
virtual std::string operator()(const Helper* r) const
{
O o = (r->*_getFn)();
- I* v = dynamic_cast<I*>(IceInternal::ReferenceWrapper<O>::get(o));
+ I* v = dynamicCast<I>(IceInternal::ReferenceWrapper<O>::get(o));
if(v)
{
return toString(v->*_member);
@@ -212,7 +212,7 @@ protected:
virtual std::string operator()(const Helper* r) const
{
O o = (r->*_getFn)();
- I* v = dynamic_cast<I*>(IceInternal::ReferenceWrapper<O>::get(o));
+ I* v = dynamicCast<I>(IceInternal::ReferenceWrapper<O>::get(o));
if(v)
{
return toString((v->*_memberFn)());
@@ -229,6 +229,40 @@ protected:
Y (I::*_memberFn)() const;
};
+ template<typename I, typename V> static I*
+ dynamicCast(V* v)
+ {
+ return dynamic_cast<I*>(v);
+ }
+
+ template<typename I> static I*
+ dynamicCast(Ice::EndpointInfo* v)
+ {
+ for(Ice::EndpointInfo* info = v; info; info = info->underlying.get())
+ {
+ I* i = dynamic_cast<I*>(info);
+ if(i)
+ {
+ return i;
+ }
+ }
+ return 0;
+ }
+
+ template<typename I> static I*
+ dynamicCast(Ice::ConnectionInfo* v)
+ {
+ for(Ice::ConnectionInfo* info = v; info; info = info->underlying.get())
+ {
+ I* i = dynamic_cast<I*>(info);
+ if(i)
+ {
+ return i;
+ }
+ }
+ return 0;
+ }
+
template<typename I> static std::string
toString(const I& v)
{
@@ -242,7 +276,7 @@ protected:
{
return p->ice_toString();
}
-
+
static const std::string&
toString(const std::string& s)
{
diff --git a/cpp/include/Ice/RegisterPlugins.h b/cpp/include/Ice/RegisterPlugins.h
index 501811453e8..9d02facefdc 100644
--- a/cpp/include/Ice/RegisterPlugins.h
+++ b/cpp/include/Ice/RegisterPlugins.h
@@ -34,10 +34,6 @@ namespace Ice
// inconsistent DLL linkage errors on Windows.
//
-#ifndef ICE_API_EXPORTS
-ICE_PLUGIN_REGISTER_DECLSPEC_IMPORT void registerIceStringConverter(bool = true);
-#endif
-
#ifndef ICE_SSL_API_EXPORTS
ICE_PLUGIN_REGISTER_DECLSPEC_IMPORT void registerIceSSL(bool = true);
#endif
@@ -54,6 +50,11 @@ ICE_PLUGIN_REGISTER_DECLSPEC_IMPORT void registerIceLocatorDiscovery(bool = true
ICE_PLUGIN_REGISTER_DECLSPEC_IMPORT void registerIceBT(bool = true);
#endif
+#if defined(__APPLE__) && TARGET_OS_IPHONE != 0
+#ifndef ICE_IAP_API_EXPORTS
+ICE_PLUGIN_REGISTER_DECLSPEC_IMPORT void registerIceIAP(bool = true);
+#endif
+#endif
#if defined(_MSC_VER) && !defined(ICE_BUILDING_SRC)
# pragma comment(lib, ICE_LIBNAME("IceDiscovery"))
diff --git a/java/src/Ice/src/main/java/IceInternal/WSEndpointDelegate.java b/cpp/include/IceIAP/IceIAP.h
index 158fd811c43..c494dc799e0 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSEndpointDelegate.java
+++ b/cpp/include/IceIAP/IceIAP.h
@@ -7,13 +7,12 @@
//
// **********************************************************************
-package IceInternal;
+#ifndef ICE_IAP_ICE_IAP_H
+#define ICE_IAP_ICE_IAP_H
-//
-// Delegate interface implemented by TcpEndpoint or IceSSL.EndpointI or any endpoint that WS can
-// delegate to.
-//
-public interface WSEndpointDelegate
-{
- Ice.EndpointInfo getWSInfo(String resource);
-};
+#include <IceUtil/PushDisableWarnings.h>
+#include <IceIAP/EndpointInfo.h>
+#include <IceIAP/ConnectionInfo.h>
+#include <IceUtil/PopDisableWarnings.h>
+
+#endif
diff --git a/cpp/include/IceSSL/Config.h b/cpp/include/IceSSL/Config.h
index db8648bdda7..61794c499ae 100644
--- a/cpp/include/IceSSL/Config.h
+++ b/cpp/include/IceSSL/Config.h
@@ -25,8 +25,15 @@
#if defined(__APPLE__)
# define ICE_USE_SECURE_TRANSPORT 1
+#if defined(__APPLE__) && TARGET_OS_IPHONE != 0
+# define ICE_USE_SECURE_TRANSPORT_IOS 1
+#else
+# define ICE_USE_SECURE_TRANSPORT_MACOS 1
+#endif
#elif defined(_WIN32)
-# define ICE_USE_SCHANNEL 1
+# if !defined(ICE_OS_WINRT)
+# define ICE_USE_SCHANNEL 1
+# endif
#else
# define ICE_USE_OPENSSL 1
#endif
diff --git a/cpp/include/IceSSL/IceSSL.h b/cpp/include/IceSSL/IceSSL.h
index 4f837df8920..a4e8719b6dc 100644
--- a/cpp/include/IceSSL/IceSSL.h
+++ b/cpp/include/IceSSL/IceSSL.h
@@ -12,7 +12,7 @@
#include <IceUtil/PushDisableWarnings.h>
#include <IceUtil/Config.h>
-#if !defined(ICE_OS_WINRT) && (!defined(__APPLE__) || TARGET_OS_IPHONE == 0)
+#if !defined(ICE_OS_WINRT)
# include <IceSSL/Plugin.h>
#endif
#include <IceSSL/EndpointInfo.h>
diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h
index 91c25e0e1a2..6987dfa71ca 100644
--- a/cpp/include/IceSSL/Plugin.h
+++ b/cpp/include/IceSSL/Plugin.h
@@ -21,13 +21,16 @@
// For struct sockaddr_storage
#ifdef _WIN32
+#ifndef ICE_OS_WINRT
# include <winsock2.h>
+#endif
#else
# include <sys/socket.h>
#endif
#if defined(ICE_USE_SECURE_TRANSPORT)
# include <CoreFoundation/CFError.h>
+# include <Security/Security.h>
#elif defined(ICE_USE_SCHANNEL)
# include <wincrypt.h>
#endif
@@ -50,49 +53,26 @@
// connections.
//
typedef struct ssl_ctx_st SSL_CTX;
+typedef struct X509_name_st X509NAME;
-//
-// Pointer to an opaque certificate object. X509_st is the OpenSSL
-// type that represents a certificate.
-//
typedef struct x509_st* X509CertificateRef;
-
-//
-// EVP_PKEY is the OpenSSL type that represents a public key.
-//
typedef struct evp_pkey_st* KeyRef;
-//
-// Type that represents an X509 distinguished name
-//
-typedef struct X509_name_st X509NAME;
-
#elif defined(ICE_USE_SECURE_TRANSPORT)
-//
-// Pointer to an opaque certificate object.
-//
-struct OpaqueSecCertificateRef;
-typedef struct OpaqueSecCertificateRef* X509CertificateRef;
-
-//
-// Pointer to an opaque key object.
-//
-struct OpaqueSecKeyRef;
-typedef struct OpaqueSecKeyRef* KeyRef;
+typedef SecCertificateRef X509CertificateRef;
+typedef SecKeyRef KeyRef;
#elif defined(ICE_USE_SCHANNEL)
-//
-// Pointer to an opaque certificate object.
-//
typedef CERT_SIGNED_CONTENT_INFO* X509CertificateRef;
-
-//
-// Pointer to an opaque key object.
-//
typedef CERT_PUBLIC_KEY_INFO* KeyRef;
+#elif defined(ICE_OS_WINRT)
+
+typedef Windows::Security::Cryptography::Certificates::Certificate^ X509CertificateRef;
+typedef Windows::Security::Cryptography::Core::CryptographicKey^ KeyRef;
+
#endif
namespace IceSSL
@@ -232,6 +212,10 @@ public:
DistinguishedName(X509NAME*);
#endif
+#if defined(__APPLE__) && TARGET_OS_IPHONE != 0
+ DistinguishedName(CFDataRef);
+#endif
+
//
// Create a DistinguishedName from a string encoded using
// the rules in RFC2253.
@@ -288,8 +272,8 @@ public:
// Construct a certificate using a native certificate.
//
// The Certificate class assumes ownership of the given native
- // certificate.
//
+ // certificate.
Certificate(X509CertificateRef);
~Certificate();
@@ -344,6 +328,8 @@ public:
//
std::string encode() const;
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
+
//
// Checks that the certificate is currently valid, that is, the current
// date falls between the validity period given in the certificate.
@@ -364,6 +350,7 @@ public:
// Get the not-before validity time.
//
IceUtil::Time getNotBefore() const;
+#endif
//
// Get the serial number. This is an arbitrarily large number.
@@ -385,6 +372,7 @@ public:
//
DistinguishedName getIssuerDN() const;
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
//
// Get the values in the issuer's alternative names extension.
//
@@ -412,16 +400,19 @@ public:
// X509* certificate to obtain these values.
//
std::vector<std::pair<int, std::string> > getIssuerAlternativeNames();
+#endif
//
// Get the subject's distinguished name (DN).
//
DistinguishedName getSubjectDN() const;
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
//
// See the comment for getIssuerAlternativeNames.
//
std::vector<std::pair<int, std::string> > getSubjectAlternativeNames();
+#endif
//
// Retrieve the certificate version number.
@@ -453,6 +444,13 @@ private:
#ifdef ICE_USE_SCHANNEL
CERT_INFO* _certInfo;
#endif
+#if defined(__APPLE__) && TARGET_OS_IPHONE != 0
+ void initializeAttributes() const;
+ mutable CFDataRef _subject;
+ mutable CFDataRef _issuer;
+ mutable std::string _serial;
+ mutable int _version;
+#endif
};
//
@@ -473,23 +471,6 @@ public:
ICE_DEFINE_PTR(NativeConnectionInfoPtr, NativeConnectionInfo);
//
-// WSSNativeConnectionInfo is an extension of IceSSL::WSSConnectionInfo
-// that provides access to native certificates.
-//
-class ICE_SSL_API WSSNativeConnectionInfo : public WSSConnectionInfo
-{
-public:
-
- //
- // The certificate chain. This may be empty if the peer did not
- // supply a certificate. The peer's certificate (if any) is the
- // first one in the chain.
- //
- std::vector<CertificatePtr> nativeCerts;
-};
-ICE_DEFINE_PTR(WSSNativeConnectionInfoPtr, WSSNativeConnectionInfo);
-
-//
// An application can customize the certificate verification process
// by implementing the CertificateVerifier interface.
//
diff --git a/cpp/msbuild/ice.proj b/cpp/msbuild/ice.proj
index be7fdcdbda9..c300162a7fd 100644
--- a/cpp/msbuild/ice.proj
+++ b/cpp/msbuild/ice.proj
@@ -125,7 +125,7 @@
</DistSolution>
</ItemGroup>
- <!-- ARM Buidls require Win32 for the Slice translators -->
+ <!-- ARM Builds require Win32 for the Slice translators -->
<ItemGroup Condition="'$(Platform)' == 'ARM'">
<DistSolution Include="ice.$(DefaultPlatformToolset).sln">
<Properties>Configuration=$(Configuration);Platform=Win32</Properties>
diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp
index 89508705051..4d46d210726 100644
--- a/cpp/src/Glacier2/SessionRouterI.cpp
+++ b/cpp/src/Glacier2/SessionRouterI.cpp
@@ -1,3 +1,4 @@
+
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
@@ -90,6 +91,21 @@ private:
const SessionRouterIPtr _router;
const Ice::ConnectionPtr _connection;
};
+
+Ice::IPConnectionInfoPtr
+getIPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPConnectionInfoPtr ipInfo = Ice::IPConnectionInfoPtr::dynamicCast(p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
}
namespace Glacier2
@@ -443,7 +459,7 @@ CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, const strin
{
_context["_con.type"] = current.con->type();
{
- Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(current.con->getInfo());
+ Ice::IPConnectionInfoPtr info = getIPConnectionInfo(current.con->getInfo());
if(info)
{
ostringstream os;
@@ -832,10 +848,11 @@ SessionRouterI::createSessionFromSecureConnection_async(
amdCB->ice_exception(PermissionDeniedException("not ssl connection"));
return;
}
- sslinfo.remotePort = info->remotePort;
- sslinfo.remoteHost = info->remoteAddress;
- sslinfo.localPort = info->localPort;
- sslinfo.localHost = info->localAddress;
+ Ice::IPConnectionInfoPtr ipInfo = getIPConnectionInfo(info);
+ sslinfo.remotePort = ipInfo->remotePort;
+ sslinfo.remoteHost = ipInfo->remoteAddress;
+ sslinfo.localPort = ipInfo->localPort;
+ sslinfo.localHost = ipInfo->localAddress;
sslinfo.cipher = info->cipher;
sslinfo.certs = info->certs;
if(info->certs.size() > 0)
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index 4f038bea61f..2abec6e1a82 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -3642,9 +3642,15 @@ Ice::ConnectionI::initConnectionInfo() const
{
_info = ICE_MAKE_SHARED(ConnectionInfo);
}
- _info->connectionId = _endpoint->connectionId();
- _info->incoming = _connector == 0;
- _info->adapterName = _adapter ? _adapter->getName() : string();
+
+ Ice::ConnectionInfoPtr info = _info;
+ while(info)
+ {
+ info->connectionId = _endpoint->connectionId();
+ info->incoming = _connector == 0;
+ info->adapterName = _adapter ? _adapter->getName() : string();
+ info = info->underlying;
+ }
return _info;
}
diff --git a/cpp/src/Ice/EndpointFactory.h b/cpp/src/Ice/EndpointFactory.h
index 09c4912d53e..07b3fbd32f2 100644
--- a/cpp/src/Ice/EndpointFactory.h
+++ b/cpp/src/Ice/EndpointFactory.h
@@ -39,7 +39,7 @@ public:
virtual EndpointIPtr read(Ice::InputStream*) const = 0;
virtual void destroy() = 0;
- virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const = 0;
+ virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const = 0;
protected:
diff --git a/cpp/src/Ice/EndpointI.cpp b/cpp/src/Ice/EndpointI.cpp
index 31e98dacbd6..af4a2244602 100644
--- a/cpp/src/Ice/EndpointI.cpp
+++ b/cpp/src/Ice/EndpointI.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <Ice/EndpointI.h>
+#include <Ice/OutputStream.h>
using namespace std;
@@ -16,6 +17,14 @@ IceUtil::Shared* IceInternal::upCast(EndpointI* p) { return p; }
IceUtil::Shared* IceInternal::upCast(EndpointI_connectors* p) { return p; }
#endif
+void
+IceInternal::EndpointI::streamWrite(Ice::OutputStream* s) const
+{
+ s->startEncapsulation();
+ streamWriteImpl(s);
+ s->endEncapsulation();
+}
+
string
IceInternal::EndpointI::toString() const
{
diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h
index 1f4ae56117e..b2260474d3d 100644
--- a/cpp/src/Ice/EndpointI.h
+++ b/cpp/src/Ice/EndpointI.h
@@ -46,7 +46,8 @@ public:
//
// Marshal the endpoint.
//
- virtual void streamWrite(Ice::OutputStream*) const = 0;
+ virtual void streamWrite(Ice::OutputStream*) const;
+ virtual void streamWriteImpl(Ice::OutputStream*) const = 0;
//
// Return the endpoint type.
@@ -177,6 +178,8 @@ public:
InfoI(const EndpointIPtr& endpoint) : _endpoint(endpoint)
{
+ T::compress = _endpoint->compress();
+ T::timeout = _endpoint->timeout();
}
virtual Ice::Short
diff --git a/cpp/src/Ice/IPEndpointI.cpp b/cpp/src/Ice/IPEndpointI.cpp
index 824864a7588..21f4def1c2d 100644
--- a/cpp/src/Ice/IPEndpointI.cpp
+++ b/cpp/src/Ice/IPEndpointI.cpp
@@ -106,11 +106,10 @@ IceInternal::IPEndpointI::secure() const
}
void
-IceInternal::IPEndpointI::streamWrite(OutputStream* s) const
+IceInternal::IPEndpointI::streamWriteImpl(OutputStream* s) const
{
- s->startEncapsulation();
- streamWriteImpl(s);
- s->endEncapsulation();
+ s->write(_host, false);
+ s->write(_port);
}
const string&
@@ -132,18 +131,6 @@ IceInternal::IPEndpointI::connectionId(const string& connectionId) const
}
}
-const std::string&
-IceInternal::IPEndpointI::host() const
-{
- return _host;
-}
-
-int
-IceInternal::IPEndpointI::port() const
-{
- return _port;
-}
-
void
IceInternal::IPEndpointI::connectors_async(Ice::EndpointSelectionType selType, const EndpointI_connectorsPtr& cb) const
{
@@ -355,13 +342,6 @@ IceInternal::IPEndpointI::connectors(const vector<Address>& addresses, const Net
}
void
-IceInternal::IPEndpointI::streamWriteImpl(OutputStream* s) const
-{
- s->write(_host, false);
- s->write(_port);
-}
-
-void
IceInternal::IPEndpointI::hashInit(Ice::Int& h) const
{
hashAdd(h, _host);
diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h
index 3c6e520da2e..a2ed7984037 100644
--- a/cpp/src/Ice/IPEndpointI.h
+++ b/cpp/src/Ice/IPEndpointI.h
@@ -47,11 +47,12 @@ class ICE_API IPEndpointI : public EndpointI, public Ice::EnableSharedFromThis<I
{
public:
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
+
virtual Ice::EndpointInfoPtr getInfo() const;
virtual Ice::Short type() const;
virtual const std::string& protocol() const;
virtual bool secure() const;
- virtual void streamWrite(Ice::OutputStream*) const;
virtual const std::string& connectionId() const;
virtual EndpointIPtr connectionId(const ::std::string&) const;
@@ -71,10 +72,7 @@ public:
#endif
virtual std::vector<ConnectorPtr> connectors(const std::vector<Address>&, const NetworkProxyPtr&) const;
- const std::string& host() const;
- int port() const;
- virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual void hashInit(Ice::Int&) const;
virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const;
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index 5e7e0616943..5bd91cb36c3 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -183,11 +183,14 @@ IceInternal::IncomingBase::__warning(const Exception& ex) const
if(_current.con)
{
- Ice::ConnectionInfoPtr connInfo = _current.con->getInfo();
- Ice::IPConnectionInfoPtr ipConnInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connInfo);
- if(ipConnInfo)
+ for(Ice::ConnectionInfoPtr connInfo = _current.con->getInfo(); connInfo; connInfo = connInfo->underlying)
{
- out << "\nremote host: " << ipConnInfo->remoteAddress << " remote port: " << ipConnInfo->remotePort;
+ Ice::IPConnectionInfoPtr ipConnInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connInfo);
+ if(ipConnInfo)
+ {
+ out << "\nremote host: " << ipConnInfo->remoteAddress << " remote port: " << ipConnInfo->remotePort;
+ break;
+ }
}
}
}
@@ -204,11 +207,14 @@ IceInternal::IncomingBase::__warning(const string& msg) const
if(_current.con)
{
- Ice::ConnectionInfoPtr connInfo = _current.con->getInfo();
- Ice::IPConnectionInfoPtr ipConnInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connInfo);
- if(ipConnInfo)
+ for(Ice::ConnectionInfoPtr connInfo = _current.con->getInfo(); connInfo; connInfo = connInfo->underlying)
{
- out << "\nremote host: " << ipConnInfo->remoteAddress << " remote port: " << ipConnInfo->remotePort;
+ Ice::IPConnectionInfoPtr ipConnInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connInfo);
+ if(ipConnInfo)
+ {
+ out << "\nremote host: " << ipConnInfo->remoteAddress << " remote port: " << ipConnInfo->remotePort;
+ break;
+ }
}
}
}
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index a561645ea64..460ec504c4f 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -1115,7 +1115,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
#endif
if(!logfile.empty())
{
- _initData.logger = ICE_MAKE_SHARED(LoggerI, _initData.properties->getProperty("Ice.ProgramName"), logfile, true, ICE_NULLPTR,
+ _initData.logger = ICE_MAKE_SHARED(LoggerI, _initData.properties->getProperty("Ice.ProgramName"), logfile, true, ICE_NULLPTR,
_initData.properties->getPropertyAsIntWithDefault("Ice.LogFile.SizeMax", 0));
}
else
@@ -1330,13 +1330,13 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[], const Ice::Communica
if(tcpFactory)
{
ProtocolInstancePtr instance = new ProtocolInstance(communicator, WSEndpointType, "ws", false);
- _endpointFactoryManager->add(new WSEndpointFactory(instance, tcpFactory->clone(instance)));
+ _endpointFactoryManager->add(new WSEndpointFactory(instance, tcpFactory->clone(instance, 0)));
}
EndpointFactoryPtr sslFactory = _endpointFactoryManager->get(SSLEndpointType);
if(sslFactory)
{
ProtocolInstancePtr instance = new ProtocolInstance(communicator, WSSEndpointType, "wss", true);
- _endpointFactoryManager->add(new WSEndpointFactory(instance, sslFactory->clone(instance)));
+ _endpointFactoryManager->add(new WSEndpointFactory(instance, sslFactory->clone(instance, 0)));
}
//
@@ -1838,9 +1838,9 @@ IceInternal::Instance::addObjectFactory(const Ice::ObjectFactoryPtr& factory, co
//
#ifdef ICE_CPP11_MAPPING
_initData.valueFactoryManager->add([factory](const string& id)
- {
- return factory->create(id);
- },
+ {
+ return factory->create(id);
+ },
id);
#else
class ValueFactoryWrapper: public Ice::ValueFactory
diff --git a/cpp/src/Ice/InstrumentationI.cpp b/cpp/src/Ice/InstrumentationI.cpp
index 6fbedad641f..62f8bda1285 100644
--- a/cpp/src/Ice/InstrumentationI.cpp
+++ b/cpp/src/Ice/InstrumentationI.cpp
@@ -74,6 +74,20 @@ struct ThreadStateChanged
ThreadState newState;
};
+IPConnectionInfo*
+getIPConnectionInfo(const ConnectionInfoPtr& info)
+{
+ for(ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ IPConnectionInfo* ipInfo = dynamic_cast<IPConnectionInfo*>(p.get());
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
class ConnectionHelper : public MetricsHelperT<ConnectionMetrics>
{
public:
@@ -108,7 +122,7 @@ public:
if(_id.empty())
{
ostringstream os;
- IPConnectionInfoPtr info = ICE_DYNAMIC_CAST(IPConnectionInfo, _connectionInfo);
+ IPConnectionInfo* info = getIPConnectionInfo(_connectionInfo);
if(info)
{
os << info->localAddress << ':' << info->localPort;
diff --git a/cpp/src/Ice/Makefile.mk b/cpp/src/Ice/Makefile.mk
index fe90b914e73..44890c32c18 100644
--- a/cpp/src/Ice/Makefile.mk
+++ b/cpp/src/Ice/Makefile.mk
@@ -26,8 +26,6 @@ Ice_excludes += src/IceUtil/ConvertUTF.cpp src/IceUtil/Unicode.cpp
endif
Ice[iphoneos]_extra_sources := $(wildcard $(addprefix $(currentdir)/ios/,*.cpp *.mm))
-Ice[iphoneos]_excludes := $(currentdir)/RegisterPluginsInit.cpp
Ice[iphonesimulator]_extra_sources = $(Ice[iphoneos]_extra_sources)
-Ice[iphonesimulator]_excludes = $(Ice[iphoneos]_excludes)
projects += $(project)
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index d1da40b9b51..317e1e3bbc4 100644..100755
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -812,12 +812,112 @@ IceInternal::NativeInfo::completed(SocketOperation operation)
#elif defined(ICE_OS_WINRT)
void
+IceInternal::NativeInfo::queueAction(SocketOperation op, IAsyncAction^ action, bool connect)
+{
+ AsyncInfo* asyncInfo = getAsyncInfo(op);
+ if(checkIfErrorOrCompleted(op, action, connect))
+ {
+ asyncInfo->count = 0;
+ }
+ else
+ {
+ action->Completed = ref new AsyncActionCompletedHandler(
+ [=] (IAsyncAction^ info, Windows::Foundation::AsyncStatus status)
+ {
+ if(status != Windows::Foundation::AsyncStatus::Completed)
+ {
+ asyncInfo->count = SOCKET_ERROR;
+ asyncInfo->error = info->ErrorCode.Value;
+ }
+ else
+ {
+ asyncInfo->count = 0;
+ }
+ completed(op);
+ });
+ }
+}
+
+void
+IceInternal::NativeInfo::queueOperation(SocketOperation op, IAsyncOperation<unsigned int>^ operation)
+{
+ AsyncInfo* info = getAsyncInfo(op);
+ if(checkIfErrorOrCompleted(op, operation))
+ {
+ info->count = static_cast<int>(operation->GetResults());
+ }
+ else
+ {
+ if(!info->completedHandler)
+ {
+ info->completedHandler = ref new AsyncOperationCompletedHandler<unsigned int>(
+ [=] (IAsyncOperation<unsigned int>^ operation, Windows::Foundation::AsyncStatus status)
+ {
+ if(status != Windows::Foundation::AsyncStatus::Completed)
+ {
+ info->count = SOCKET_ERROR;
+ info->error = operation->ErrorCode.Value;
+ }
+ else
+ {
+ info->count = static_cast<int>(operation->GetResults());
+ }
+ completed(op);
+ });
+ }
+ operation->Completed = info->completedHandler;
+ }
+}
+
+void
+IceInternal::NativeInfo::setCompletedHandler(SocketOperationCompletedHandler^ handler)
+{
+ _completedHandler = handler;
+}
+
+void
IceInternal::NativeInfo::completed(SocketOperation operation)
{
assert(_completedHandler);
_completedHandler(operation);
}
+bool
+IceInternal::NativeInfo::checkIfErrorOrCompleted(SocketOperation op, IAsyncInfo^ info, bool connect)
+{
+ //
+ // NOTE: It's important to only check for info->Status once as it
+ // might change during the checks below (the Status can be changed
+ // by the Windows thread pool concurrently).
+ //
+ // We consider that a canceled async status is the same as an
+ // error. A canceled async status can occur if there's a timeout
+ // and the socket is closed.
+ //
+ Windows::Foundation::AsyncStatus status = info->Status;
+ if(status == Windows::Foundation::AsyncStatus::Completed)
+ {
+ _completedHandler(op);
+ return true;
+ }
+ else if (status == Windows::Foundation::AsyncStatus::Started)
+ {
+ return false;
+ }
+ else
+ {
+ if(connect) // Connect
+ {
+ checkConnectErrorCode(__FILE__, __LINE__, info->ErrorCode.Value);
+ }
+ else
+ {
+ checkErrorCode(__FILE__, __LINE__, info->ErrorCode.Value);
+ }
+ return true; // Prevent compiler warning.
+ }
+}
+
#endif
bool
@@ -1996,6 +2096,9 @@ IceInternal::setReuseAddress(SOCKET fd, bool reuse)
#ifdef ICE_OS_WINRT
+namespace
+{
+
void
checkResultAndWait(IAsyncAction^ action)
{
@@ -2023,6 +2126,8 @@ checkResultAndWait(IAsyncAction^ action)
checkErrorCode(__FILE__, __LINE__, action->ErrorCode.Value);
}
}
+
+}
#endif
Address
@@ -2561,7 +2666,7 @@ IceInternal::createPipe(SOCKET fds[2])
#else // ICE_OS_WINRT
void
-IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr, HostName^ host)
+IceInternal::checkConnectErrorCode(const char* file, int line, HRESULT herr)
{
if(herr == E_ACCESSDENIED)
{
@@ -2591,11 +2696,6 @@ 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
- // Windows API.
- //
- ex.host = IceUtil::wstringToString(host->RawName->Data(), IceUtil::getProcessStringConverter());
throw ex;
}
else
diff --git a/cpp/src/Ice/Network.h b/cpp/src/Ice/Network.h
index 5d40847bdde..aae80089dbe 100644..100755
--- a/cpp/src/Ice/Network.h
+++ b/cpp/src/Ice/Network.h
@@ -179,6 +179,7 @@ struct ICE_API AsyncInfo : WSAOVERLAPPED
#elif defined(ICE_OS_WINRT)
struct ICE_API AsyncInfo
{
+ Windows::Foundation::AsyncOperationCompletedHandler<unsigned int>^ completedHandler;
int count;
int error;
};
@@ -221,10 +222,13 @@ public:
#if defined(ICE_USE_IOCP)
virtual AsyncInfo* getAsyncInfo(SocketOperation) = 0;
void initialize(HANDLE, ULONG_PTR);
- void completed(SocketOperation operation);
+ void completed(SocketOperation);
#elif defined(ICE_OS_WINRT)
- virtual void setCompletedHandler(SocketOperationCompletedHandler^) = 0;
- void completed(SocketOperation operation);
+ virtual AsyncInfo* getAsyncInfo(SocketOperation) = 0;
+ void queueAction(SocketOperation, Windows::Foundation::IAsyncAction^, bool = false);
+ void queueOperation(SocketOperation, Windows::Foundation::IAsyncOperation<unsigned int>^);
+ void setCompletedHandler(SocketOperationCompletedHandler^);
+ void completed(SocketOperation);
#endif
protected:
@@ -236,6 +240,7 @@ protected:
HANDLE _handle;
ULONG_PTR _key;
#elif defined(ICE_OS_WINRT)
+ bool checkIfErrorOrCompleted(SocketOperation, Windows::Foundation::IAsyncInfo^, bool = false);
SocketOperationCompletedHandler^ _completedHandler;
#endif
};
@@ -287,6 +292,7 @@ ICE_API void setMcastTtl(SOCKET, int, const Address&);
ICE_API void setReuseAddress(SOCKET, bool);
ICE_API Address doBind(SOCKET, const Address&);
+ICE_API void doListen(SOCKET, int);
#ifndef ICE_OS_WINRT
ICE_API bool interrupted();
@@ -301,7 +307,6 @@ ICE_API bool connectionRefused();
ICE_API bool connectInProgress();
ICE_API bool connectionLost();
-ICE_API void doListen(SOCKET, int);
ICE_API bool doConnect(SOCKET, const Address&, const Address&);
ICE_API void doFinishConnect(SOCKET);
ICE_API SOCKET doAccept(SOCKET);
@@ -312,7 +317,7 @@ 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 checkConnectErrorCode(const char*, int, HRESULT);
ICE_API void checkErrorCode(const char*, int, HRESULT);
#endif
diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp
index 838fcc6252f..d6c8bdbf984 100644
--- a/cpp/src/Ice/OpaqueEndpointI.cpp
+++ b/cpp/src/Ice/OpaqueEndpointI.cpp
@@ -92,7 +92,7 @@ private:
//
OpaqueEndpointInfoI::OpaqueEndpointInfoI(Ice::Short type, const Ice::EncodingVersion& rawEncoding,
const Ice::ByteSeq& rawBytes) :
- Ice::OpaqueEndpointInfo(-1, false, rawEncoding, rawBytes),
+ Ice::OpaqueEndpointInfo(ICE_NULLPTR, -1, false, rawEncoding, rawBytes),
_type(type)
{
}
@@ -320,6 +320,12 @@ IceInternal::OpaqueEndpointI::operator<(const LocalObject& r) const
return false;
}
+void
+IceInternal::OpaqueEndpointI::streamWriteImpl(Ice::OutputStream*) const
+{
+ assert(false);
+}
+
bool
IceInternal::OpaqueEndpointI::checkOption(const string& option, const string& argument, const string& endpoint)
{
diff --git a/cpp/src/Ice/OpaqueEndpointI.h b/cpp/src/Ice/OpaqueEndpointI.h
index fa4add29b16..a0ebae3a49f 100644
--- a/cpp/src/Ice/OpaqueEndpointI.h
+++ b/cpp/src/Ice/OpaqueEndpointI.h
@@ -57,6 +57,7 @@ public:
protected:
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual bool checkOption(const std::string&, const std::string&, const std::string&);
private:
diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp
index 580d51d74fe..ade367f2a40 100644
--- a/cpp/src/Ice/Selector.cpp
+++ b/cpp/src/Ice/Selector.cpp
@@ -22,12 +22,10 @@
using namespace std;
using namespace IceInternal;
-#ifdef ICE_OS_WINRT
-//using namespace Windows::Foundation;
+#if defined(ICE_OS_WINRT)
using namespace Windows::Storage::Streams;
using namespace Windows::Networking;
using namespace Windows::Networking::Sockets;
-
#endif
#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
diff --git a/cpp/src/Ice/StreamSocket.cpp b/cpp/src/Ice/StreamSocket.cpp
index fa3761f5fa0..7d186e15dd4 100644..100755
--- a/cpp/src/Ice/StreamSocket.cpp
+++ b/cpp/src/Ice/StreamSocket.cpp
@@ -13,6 +13,14 @@
using namespace IceInternal;
+#if defined(ICE_OS_WINRT)
+
+#include <Ice/Properties.h>
+using namespace Platform;
+using namespace Windows::Foundation;
+
+#endif
+
StreamSocket::StreamSocket(const ProtocolInstancePtr& instance,
const NetworkProxyPtr& proxy,
const Address& addr,
@@ -23,13 +31,12 @@ StreamSocket::StreamSocket(const ProtocolInstancePtr& instance,
_addr(addr),
_sourceAddr(sourceAddr),
_state(StateNeedConnect)
-#ifdef ICE_USE_IOCP
- , _read(SocketOperationRead),
- _write(SocketOperationWrite)
+#if defined(ICE_USE_IOCP)
+ , _read(SocketOperationRead), _write(SocketOperationWrite)
#endif
{
init();
-#ifndef ICE_USE_IOCP
+#if !defined(ICE_USE_IOCP) && !defined(ICE_OS_WINRT)
if(doConnect(_fd, _proxy ? _proxy->getAddress() : _addr, sourceAddr))
{
_state = _proxy ? StateProxyWrite : StateConnected;
@@ -49,10 +56,11 @@ StreamSocket::StreamSocket(const ProtocolInstancePtr& instance,
StreamSocket::StreamSocket(const ProtocolInstancePtr& instance, SOCKET fd) :
NativeInfo(fd),
_instance(instance),
- _state(StateConnected)
-#ifdef ICE_USE_IOCP
- , _read(SocketOperationRead),
- _write(SocketOperationWrite)
+ _addr(),
+ _sourceAddr(),
+ _state(StateConnected)
+#if defined(ICE_USE_IOCP)
+ , _read(SocketOperationRead), _write(SocketOperationWrite)
#endif
{
init();
@@ -82,8 +90,26 @@ StreamSocket::connect(Buffer& readBuffer, Buffer& writeBuffer)
}
else if(_state <= StateConnectPending)
{
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP)
doFinishConnectAsync(_fd, _write);
+#elif defined(ICE_OS_WINRT)
+ if(_write.count == SOCKET_ERROR)
+ {
+ try
+ {
+ checkConnectErrorCode(__FILE__, __LINE__, _write.error);
+ }
+ catch(Ice::DNSException& ex)
+ {
+ //
+ // Don't need to pass a wide string converter as the wide string come from
+ // Windows API.
+ //
+ const Address& addr = _proxy ? _proxy->getAddress() : _addr;
+ ex.host = IceUtil::wstringToString(addr.host->RawName->Data(), IceUtil::getProcessStringConverter());
+ throw;
+ }
+ }
#else
doFinishConnect(_fd);
#endif
@@ -127,7 +153,7 @@ StreamSocket::isConnected()
size_t
StreamSocket::getSendPacketSize(size_t length)
{
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
return _maxSendPacketSize > 0 ? std::min(length, _maxSendPacketSize) : length;
#else
return length;
@@ -137,7 +163,7 @@ StreamSocket::getSendPacketSize(size_t length)
size_t
StreamSocket::getRecvPacketSize(size_t length)
{
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
return _maxRecvPacketSize > 0 ? std::min(length, _maxRecvPacketSize) : length;
#else
return length;
@@ -153,6 +179,7 @@ StreamSocket::setBufferSize(int rcvSize, int sndSize)
SocketOperation
StreamSocket::read(Buffer& buf)
{
+#if !defined(ICE_OS_WINRT)
if(_state == StateProxyRead)
{
while(true)
@@ -171,12 +198,14 @@ StreamSocket::read(Buffer& buf)
}
}
buf.i += read(reinterpret_cast<char*>(&*buf.i), buf.b.end() - buf.i);
+#endif
return buf.i != buf.b.end() ? SocketOperationRead : SocketOperationNone;
}
SocketOperation
StreamSocket::write(Buffer& buf)
{
+#if !defined(ICE_OS_WINRT)
if(_state == StateProxyWrite)
{
while(true)
@@ -195,9 +224,11 @@ StreamSocket::write(Buffer& buf)
}
}
buf.i += write(reinterpret_cast<const char*>(&*buf.i), buf.b.end() - buf.i);
+#endif
return buf.i != buf.b.end() ? SocketOperationWrite : SocketOperationNone;
}
+#if !defined(ICE_OS_WINRT)
ssize_t
StreamSocket::read(char* buf, size_t length)
{
@@ -278,7 +309,6 @@ StreamSocket::write(const char* buf, size_t length)
#else
size_t packetSize = length;
#endif
-
ssize_t sent = 0;
while(length > 0)
{
@@ -336,8 +366,9 @@ StreamSocket::write(const char* buf, size_t length)
}
return sent;
}
+#endif
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
AsyncInfo*
StreamSocket::getAsyncInfo(SocketOperation op)
{
@@ -352,6 +383,9 @@ StreamSocket::getAsyncInfo(SocketOperation op)
return 0;
}
}
+#endif
+
+#if defined(ICE_USE_IOCP)
bool
StreamSocket::startWrite(Buffer& buf)
@@ -489,7 +523,132 @@ StreamSocket::finishRead(Buffer& buf)
{
_state = toState(_proxy->endRead(buf));
}
+
+}
+
+#elif defined(ICE_OS_WINRT)
+
+bool
+StreamSocket::startWrite(Buffer& buf)
+{
+ if(_state == StateConnectPending)
+ {
+ const Address& addr = _proxy ? _proxy->getAddress() : _addr;
+ try
+ {
+ try
+ {
+ queueAction(SocketOperationConnect,
+ safe_cast<Windows::Networking::Sockets::StreamSocket^>(_fd)->ConnectAsync(addr.host, addr.port,
+ Windows::Networking::Sockets::SocketProtectionLevel::PlainSocket), true);
+ }
+ catch(Platform::Exception^ ex)
+ {
+ checkConnectErrorCode(__FILE__, __LINE__, ex->HResult);
+ }
+ }
+ catch(Ice::DNSException& ex)
+ {
+ //
+ // Don't need to pass a wide string converter as the wide string come from
+ // Windows API.
+ //
+ ex.host = IceUtil::wstringToString(addr.host->RawName->Data(), IceUtil::getProcessStringConverter());
+ throw;
+ }
+ return false;
+ }
+
+ assert(!buf.b.empty());
+ assert(buf.i != buf.b.end());
+
+ size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i);
+ if(_maxSendPacketSize > 0 && packetSize > _maxSendPacketSize)
+ {
+ packetSize = _maxSendPacketSize;
+ }
+ assert(packetSize > 0);
+ _writer->WriteBytes(ref new Array<unsigned char>(&*buf.i, packetSize));
+ try
+ {
+ queueOperation(SocketOperationWrite, _writer->StoreAsync());
+ }
+ catch(Platform::Exception^ ex)
+ {
+ checkErrorCode(__FILE__, __LINE__, ex->HResult);
+ }
+ return packetSize == static_cast<int>(buf.b.end() - buf.i);
}
+
+void
+StreamSocket::finishWrite(Buffer& buf)
+{
+ if(_fd == INVALID_SOCKET || (_state < StateConnected && _state != StateProxyWrite))
+ {
+ return;
+ }
+
+ if(_write.count == SOCKET_ERROR)
+ {
+ checkErrorCode(__FILE__, __LINE__, _write.error);
+ }
+
+ buf.i += _write.count;
+}
+
+void
+StreamSocket::startRead(Buffer& buf)
+{
+ size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i);
+ if(_maxRecvPacketSize > 0 && packetSize > _maxRecvPacketSize)
+ {
+ packetSize = _maxRecvPacketSize;
+ }
+ assert(!buf.b.empty() && buf.i != buf.b.end());
+
+ try
+ {
+ queueOperation(SocketOperationRead, _reader->LoadAsync(packetSize));
+ }
+ catch(Platform::Exception^ ex)
+ {
+ checkErrorCode(__FILE__, __LINE__, ex->HResult);
+ }
+}
+
+void
+StreamSocket::finishRead(Buffer& buf)
+{
+ if(_fd == INVALID_SOCKET)
+ {
+ return;
+ }
+
+ if(_read.count == SOCKET_ERROR)
+ {
+ checkErrorCode(__FILE__, __LINE__, _read.error);
+ }
+ else if(_read.count == 0)
+ {
+ Ice::ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
+ }
+
+ try
+ {
+ auto data = ref new Platform::Array<unsigned char>(_read.count);
+ _reader->ReadBytes(data);
+ memcpy(&*buf.i, data->Data, _read.count);
+ }
+ catch(Platform::Exception^ ex)
+ {
+ checkErrorCode(__FILE__, __LINE__, ex->HResult);
+ }
+
+ buf.i += _read.count;
+}
+
#endif
void
@@ -520,7 +679,7 @@ StreamSocket::init()
setBlock(_fd, false);
setTcpBufSize(_fd, _instance);
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP)
//
// For timeouts to work properly, we need to receive or send the
// data in several chunks when using IOCP WSARecv or WSASend.
@@ -530,6 +689,14 @@ StreamSocket::init()
//
_maxSendPacketSize = std::max(512, IceInternal::getSendBufferSize(_fd));
_maxRecvPacketSize = std::max(512, IceInternal::getRecvBufferSize(_fd));
+#elif defined(ICE_OS_WINRT)
+ Windows::Networking::Sockets::StreamSocket^ s = safe_cast<Windows::Networking::Sockets::StreamSocket^>(_fd);
+ _writer = ref new Windows::Storage::Streams::DataWriter(s->OutputStream);
+ _reader = ref new Windows::Storage::Streams::DataReader(s->InputStream);
+ _reader->InputStreamOptions = Windows::Storage::Streams::InputStreamOptions::Partial;
+
+ _maxSendPacketSize = std::max(static_cast<unsigned int>(512), s->Control->OutboundBufferSizeInBytes / 2);
+ _maxRecvPacketSize = _instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.RcvSize", 128 * 1024);
#endif
}
@@ -546,5 +713,3 @@ StreamSocket::toState(SocketOperation operation) const
return StateProxyConnected;
}
}
-
-
diff --git a/cpp/src/Ice/StreamSocket.h b/cpp/src/Ice/StreamSocket.h
index ad69b096199..3d092d20ba2 100644
--- a/cpp/src/Ice/StreamSocket.h
+++ b/cpp/src/Ice/StreamSocket.h
@@ -36,11 +36,16 @@ public:
SocketOperation read(Buffer&);
SocketOperation write(Buffer&);
+#if !defined(ICE_OS_WINRT)
ssize_t read(char*, size_t);
ssize_t write(const char*, size_t);
+#endif
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
AsyncInfo* getAsyncInfo(SocketOperation);
+#endif
+
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
bool startWrite(Buffer&);
void finishWrite(Buffer&);
void startRead(Buffer&);
@@ -73,12 +78,17 @@ private:
State _state;
std::string _desc;
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
size_t _maxSendPacketSize;
size_t _maxRecvPacketSize;
AsyncInfo _read;
AsyncInfo _write;
#endif
+
+#if defined(ICE_OS_WINRT)
+ Windows::Storage::Streams::DataReader^ _reader;
+ Windows::Storage::Streams::DataWriter^ _writer;
+#endif
};
typedef IceUtil::Handle<StreamSocket> StreamSocketPtr;
diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp
index 8ca874cc218..e20ad639d91 100644..100755
--- a/cpp/src/Ice/TcpAcceptor.cpp
+++ b/cpp/src/Ice/TcpAcceptor.cpp
@@ -17,8 +17,21 @@
#include <Ice/StreamSocket.h>
#include <IceUtil/StringUtil.h>
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP)
# include <Mswsock.h>
+#elif defined(ICE_OS_WINRT)
+using namespace Platform;
+using namespace Windows::Foundation;
+using namespace Windows::Storage::Streams;
+using namespace Windows::Networking;
+using namespace Windows::Networking::Sockets;
+#endif
+
+//
+// Use the system default for the listen() backlog or 511 if not defined.
+//
+#ifndef SOMAXCONN
+# define SOMAXCONN 511
#endif
using namespace std;
@@ -33,22 +46,28 @@ IceInternal::TcpAcceptor::getNativeInfo()
return this;
}
-#ifdef ICE_USE_IOCP
-AsyncInfo*
-# ifndef NDEBUG
-IceInternal::TcpAcceptor::getAsyncInfo(SocketOperation op)
-# else
-IceInternal::TcpAcceptor::getAsyncInfo(SocketOperation)
-# endif
-{
- assert(op == SocketOperationRead);
- return &_info;
-}
-#endif
-
void
IceInternal::TcpAcceptor::close()
{
+#if defined(ICE_OS_WINRT)
+ IceUtil::Mutex::Lock lock(_mutex);
+ if(_acceptPending)
+ {
+ assert(_accepted.empty());
+ completed(SocketOperationRead);
+ _acceptPending = false;
+ }
+ else if(!_accepted.empty())
+ {
+ for(deque<Windows::Networking::Sockets::StreamSocket^>::const_iterator p = _accepted.begin();
+ p != _accepted.end(); ++p)
+ {
+ closeSocket(*p);
+ }
+ _accepted.clear();
+ }
+#endif
+
if(_fd != INVALID_SOCKET)
{
closeSocketNoThrow(_fd);
@@ -62,7 +81,9 @@ IceInternal::TcpAcceptor::listen()
try
{
const_cast<Address&>(_addr) = doBind(_fd, _addr);
+#if !defined(ICE_OS_WINRT)
doListen(_fd, _backlog);
+#endif
}
catch(...)
{
@@ -73,7 +94,14 @@ IceInternal::TcpAcceptor::listen()
return _endpoint;
}
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP)
+
+AsyncInfo*
+IceInternal::TcpAcceptor::getAsyncInfo(SocketOperation)
+{
+ return &_info;
+}
+
void
IceInternal::TcpAcceptor::startAccept()
{
@@ -120,12 +148,9 @@ IceInternal::TcpAcceptor::finishAccept()
}
}
-#endif
-
TransceiverPtr
IceInternal::TcpAcceptor::accept()
{
-#ifdef ICE_USE_IOCP
if(_acceptFd == INVALID_SOCKET)
{
SocketException ex(__FILE__, __LINE__);
@@ -144,13 +169,82 @@ IceInternal::TcpAcceptor::accept()
SOCKET fd = _acceptFd;
_acceptFd = INVALID_SOCKET;
+ return new TcpTransceiver(_instance, new StreamSocket(_instance, fd));
+}
+
+#elif defined(ICE_OS_WINRT)
+
+AsyncInfo*
+IceInternal::TcpAcceptor::getAsyncInfo(SocketOperation)
+{
+ return 0; // Not used
+}
+
+void
+IceInternal::TcpAcceptor::startAccept()
+{
+ assert(_fd != INVALID_SOCKET);
+
+ //
+ // If there are already sockets waiting to be accepted, we just
+ // notify the selector that the acceptor is ready for acceting the
+ // new socket. Otherwise, we set the _acceptPending flag, when a
+ // new socket connection event is received, the message handler
+ // will notify the selector.
+ //
+ IceUtil::Mutex::Lock lock(_mutex);
+ assert(!_acceptPending);
+ if(!_accepted.empty())
+ {
+ completed(SocketOperationRead);
+ }
+ else
+ {
+ _acceptPending = true;
+ }
+}
+
+void
+IceInternal::TcpAcceptor::finishAccept()
+{
+ //
+ // Nothing to do, we just check there's at least one accepted
+ // socket or the acceptor was closed.
+ //
+ IceUtil::Mutex::Lock lock(_mutex);
+ assert(!_acceptPending && (!_accepted.empty() || _fd == INVALID_SOCKET));
+}
+
+TransceiverPtr
+IceInternal::TcpAcceptor::accept()
+{
+ if(_fd == INVALID_SOCKET) // Acceptor closed.
+ {
+ assert(_accepted.empty());
+ throw SocketException(__FILE__, __LINE__);
+ }
+
+ Windows::Networking::Sockets::StreamSocket^ fd;
+ {
+ IceUtil::Mutex::Lock lock(_mutex);
+ assert(!_accepted.empty());
+ fd = _accepted.front();
+ _accepted.pop_front();
+ }
+
+ return new TcpTransceiver(_instance, new StreamSocket(_instance, fd));
+}
+
#else
- SOCKET fd = doAccept(_fd);
-#endif
- return new TcpTransceiver(_instance, new StreamSocket(_instance, fd));
+TransceiverPtr
+IceInternal::TcpAcceptor::accept()
+{
+ return new TcpTransceiver(_instance, new StreamSocket(_instance, doAccept(_fd)));
}
+#endif
+
string
IceInternal::TcpAcceptor::protocol() const
{
@@ -191,23 +285,49 @@ IceInternal::TcpAcceptor::TcpAcceptor(const TcpEndpointIPtr& endpoint,
_instance(instance),
_addr(getAddressForServer(host, port, _instance->protocolSupport(), instance->preferIPv6()))
#ifdef ICE_USE_IOCP
- , _acceptFd(INVALID_SOCKET),
- _info(SocketOperationRead)
+ , _acceptFd(INVALID_SOCKET), _info(SocketOperationRead)
#endif
{
-#ifdef SOMAXCONN
_backlog = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.Backlog", SOMAXCONN);
+
+#if defined(ICE_OS_WINRT)
+ _fd = ref new StreamSocketListener();
+ safe_cast<StreamSocketListener^>(_fd)->ConnectionReceived +=
+ ref new TypedEventHandler<StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^>(
+ [=](StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^ args)
+ {
+ IceUtil::Mutex::Lock lock(_mutex);
+ if(_fd == INVALID_SOCKET) // Acceptor was closed.
+ {
+ closeSocket(args->Socket);
+ return;
+ }
+ _accepted.push_back(args->Socket);
+
+ //
+ // If the acceptor is waiting for a socket to be accepted, notify
+ // the selector that the acceptor is ready for "read". This will
+ // in turn caused finishAccept() and accept() to be called by the
+ // thread pool. If the acceptor isn't ready to accept the socket,
+ // it is just queued, when startAccept is called it will be dequed.
+ //
+ if(_acceptPending)
+ {
+ completed(SocketOperationRead);
+ _acceptPending = false;
+ }
+ });
#else
- _backlog = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);
+ _fd = createServerSocket(false, _addr, instance->protocolSupport());
#endif
- _fd = createServerSocket(false, _addr, instance->protocolSupport());
#ifdef ICE_USE_IOCP
_acceptBuf.resize((sizeof(sockaddr_storage) + 16) * 2);
#endif
setBlock(_fd, false);
setTcpBufSize(_fd, _instance);
+
#ifndef _WIN32
//
// Enable SO_REUSEADDR on Unix platforms to allow re-using the
diff --git a/cpp/src/Ice/TcpAcceptor.h b/cpp/src/Ice/TcpAcceptor.h
index c5e23428895..2d9fc24d72f 100644
--- a/cpp/src/Ice/TcpAcceptor.h
+++ b/cpp/src/Ice/TcpAcceptor.h
@@ -15,6 +15,10 @@
#include <Ice/Acceptor.h>
#include <Ice/Network.h>
+#if defined(ICE_OS_WINRT)
+#include <deque>
+#endif
+
namespace IceInternal
{
@@ -25,13 +29,13 @@ class TcpAcceptor : public Acceptor, public NativeInfo
public:
virtual NativeInfoPtr getNativeInfo();
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual AsyncInfo* getAsyncInfo(SocketOperation);
#endif
virtual void close();
virtual EndpointIPtr listen();
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual void startAccept();
virtual void finishAccept();
#endif
@@ -54,11 +58,15 @@ private:
const Address _addr;
int _backlog;
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP)
SOCKET _acceptFd;
int _acceptError;
std::vector<char> _acceptBuf;
AsyncInfo _info;
+#elif defined(ICE_OS_WINRT)
+ IceUtil::Mutex _mutex;
+ bool _acceptPending;
+ std::deque<Windows::Networking::Sockets::StreamSocket^> _accepted;
#endif
};
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index 1caadefbae2..2b2e26e924e 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -62,21 +62,19 @@ IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, Inp
s->read(const_cast<bool&>(_compress));
}
-EndpointInfoPtr
-IceInternal::TcpEndpointI::getInfo() const
+void
+IceInternal::TcpEndpointI::streamWriteImpl(OutputStream* s) const
{
- TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>,
- ICE_DYNAMIC_CAST(TcpEndpointI, shared_from_this()));
- fillEndpointInfo(info.get());
- return info;
+ IPEndpointI::streamWriteImpl(s);
+ s->write(_timeout);
+ s->write(_compress);
}
EndpointInfoPtr
-IceInternal::TcpEndpointI::getWSInfo(const string& resource) const
+IceInternal::TcpEndpointI::getInfo() const
{
- WSEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, shared_from_this());
+ TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, shared_from_this());
fillEndpointInfo(info.get());
- info->resource = resource;
return info;
}
@@ -254,14 +252,6 @@ IceInternal::TcpEndpointI::operator<(const LocalObject& r) const
}
void
-IceInternal::TcpEndpointI::streamWriteImpl(OutputStream* s) const
-{
- IPEndpointI::streamWriteImpl(s);
- s->write(_timeout);
- s->write(_compress);
-}
-
-void
IceInternal::TcpEndpointI::hashInit(Ice::Int& h) const
{
IPEndpointI::hashInit(h);
@@ -385,7 +375,7 @@ IceInternal::TcpEndpointFactory::destroy()
}
EndpointFactoryPtr
-IceInternal::TcpEndpointFactory::clone(const ProtocolInstancePtr& instance) const
+IceInternal::TcpEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr&) const
{
return new TcpEndpointFactory(instance);
}
diff --git a/cpp/src/Ice/TcpEndpointI.h b/cpp/src/Ice/TcpEndpointI.h
index ffc6743e213..f40c5c14713 100644
--- a/cpp/src/Ice/TcpEndpointI.h
+++ b/cpp/src/Ice/TcpEndpointI.h
@@ -14,12 +14,11 @@
#include <Ice/IPEndpointI.h>
#include <Ice/EndpointFactory.h>
#include <Ice/Network.h> // for IceIternal::Address
-#include <Ice/WSEndpoint.h>
namespace IceInternal
{
-class TcpEndpointI : public IPEndpointI, public WSEndpointDelegate
+class TcpEndpointI : public IPEndpointI, public Ice::EnableSharedFromThis<TcpEndpointI>
{
public:
@@ -28,8 +27,9 @@ public:
TcpEndpointI(const ProtocolInstancePtr&);
TcpEndpointI(const ProtocolInstancePtr&, Ice::InputStream*);
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
+
virtual Ice::EndpointInfoPtr getInfo() const;
- virtual Ice::EndpointInfoPtr getWSInfo(const std::string&) const;
virtual Ice::Int timeout() const;
virtual EndpointIPtr timeout(Ice::Int) const;
@@ -51,10 +51,10 @@ public:
TcpEndpointIPtr endpoint(const TcpAcceptorPtr&) const;
using IPEndpointI::connectionId;
+ using Ice::EnableSharedFromThis<TcpEndpointI>::shared_from_this;
protected:
- virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual void hashInit(Ice::Int&) const;
virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const;
virtual bool checkOption(const std::string&, const std::string&, const std::string&);
@@ -84,7 +84,7 @@ public:
virtual EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;
+ virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const;
private:
diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp
index 99898f4e2be..be280be0476 100644
--- a/cpp/src/Ice/TcpTransceiver.cpp
+++ b/cpp/src/Ice/TcpTransceiver.cpp
@@ -60,7 +60,7 @@ IceInternal::TcpTransceiver::read(Buffer& buf)
return _stream->read(buf);
}
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
bool
IceInternal::TcpTransceiver::startWrite(Buffer& buf)
{
@@ -108,16 +108,12 @@ Ice::ConnectionInfoPtr
IceInternal::TcpTransceiver::getInfo() const
{
TCPConnectionInfoPtr info = ICE_MAKE_SHARED(TCPConnectionInfo);
- fillConnectionInfo(info);
- return info;
-}
-
-Ice::ConnectionInfoPtr
-IceInternal::TcpTransceiver::getWSInfo(const Ice::HeaderDict& headers) const
-{
- WSConnectionInfoPtr info = ICE_MAKE_SHARED(WSConnectionInfo);
- fillConnectionInfo(info);
- info->headers = headers;
+ fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, info->remotePort);
+ if(_stream->fd() != INVALID_SOCKET)
+ {
+ info->rcvSize = getRecvBufferSize(_stream->fd());
+ info->sndSize = getSendBufferSize(_stream->fd());
+ }
return info;
}
@@ -141,14 +137,3 @@ IceInternal::TcpTransceiver::TcpTransceiver(const ProtocolInstancePtr& instance,
IceInternal::TcpTransceiver::~TcpTransceiver()
{
}
-
-void
-IceInternal::TcpTransceiver::fillConnectionInfo(const TCPConnectionInfoPtr& info) const
-{
- fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress, info->remotePort);
- if(_stream->fd() != INVALID_SOCKET)
- {
- info->rcvSize = getRecvBufferSize(_stream->fd());
- info->sndSize = getSendBufferSize(_stream->fd());
- }
-}
diff --git a/cpp/src/Ice/TcpTransceiver.h b/cpp/src/Ice/TcpTransceiver.h
index f2890ba076c..198b4aeab77 100644
--- a/cpp/src/Ice/TcpTransceiver.h
+++ b/cpp/src/Ice/TcpTransceiver.h
@@ -14,7 +14,6 @@
#include <Ice/Transceiver.h>
#include <Ice/Network.h>
#include <Ice/StreamSocket.h>
-#include <Ice/WSTransceiver.h>
namespace IceInternal
{
@@ -22,7 +21,7 @@ namespace IceInternal
class TcpConnector;
class TcpAcceptor;
-class TcpTransceiver : public Transceiver, public WSTransceiverDelegate
+class TcpTransceiver : public Transceiver
{
public:
@@ -37,7 +36,7 @@ public:
virtual void close();
virtual SocketOperation write(Buffer&);
virtual SocketOperation read(Buffer&);
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual bool startWrite(Buffer&);
virtual void finishWrite(Buffer&);
virtual void startRead(Buffer&);
@@ -47,7 +46,6 @@ public:
virtual std::string toString() const;
virtual std::string toDetailedString() const;
virtual Ice::ConnectionInfoPtr getInfo() const;
- virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const;
virtual void checkSendSize(const Buffer&);
virtual void setBufferSize(int rcvSize, int sndSize);
@@ -56,8 +54,6 @@ private:
TcpTransceiver(const ProtocolInstancePtr&, const StreamSocketPtr&);
virtual ~TcpTransceiver();
- void fillConnectionInfo(const Ice::TCPConnectionInfoPtr&) const;
-
friend class TcpConnector;
friend class TcpAcceptor;
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp
index f5b3e20982a..2adf5dc32cc 100644
--- a/cpp/src/Ice/UdpEndpointI.cpp
+++ b/cpp/src/Ice/UdpEndpointI.cpp
@@ -76,10 +76,24 @@ IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, Inp
s->read(const_cast<bool&>(_compress));
}
+void
+IceInternal::UdpEndpointI::streamWriteImpl(OutputStream* s) const
+{
+ IPEndpointI::streamWriteImpl(s);
+ if(s->getEncoding() == Ice::Encoding_1_0)
+ {
+ s->write(Ice::Protocol_1_0);
+ s->write(Ice::Encoding_1_0);
+ }
+ // Not transmitted.
+ //s->write(_connect);
+ s->write(_compress);
+}
+
EndpointInfoPtr
IceInternal::UdpEndpointI::getInfo() const
{
- Ice::UDPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::UDPEndpointInfo>,
+ Ice::UDPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::UDPEndpointInfo>,
ICE_DYNAMIC_CAST(UdpEndpointI, shared_from_this()));
fillEndpointInfo(info.get());
return info;
@@ -287,20 +301,6 @@ IceInternal::UdpEndpointI::operator<(const LocalObject& r) const
}
void
-IceInternal::UdpEndpointI::streamWriteImpl(OutputStream* s) const
-{
- IPEndpointI::streamWriteImpl(s);
- if(s->getEncoding() == Ice::Encoding_1_0)
- {
- s->write(Ice::Protocol_1_0);
- s->write(Ice::Encoding_1_0);
- }
- // Not transmitted.
- //s->write(_connect);
- s->write(_compress);
-}
-
-void
IceInternal::UdpEndpointI::hashInit(Ice::Int& h) const
{
IPEndpointI::hashInit(h);
@@ -463,7 +463,7 @@ IceInternal::UdpEndpointFactory::destroy()
}
EndpointFactoryPtr
-IceInternal::UdpEndpointFactory::clone(const ProtocolInstancePtr& instance) const
+IceInternal::UdpEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr&) const
{
return new UdpEndpointFactory(instance);
}
diff --git a/cpp/src/Ice/UdpEndpointI.h b/cpp/src/Ice/UdpEndpointI.h
index d534c52c5bb..883b725e688 100644
--- a/cpp/src/Ice/UdpEndpointI.h
+++ b/cpp/src/Ice/UdpEndpointI.h
@@ -27,6 +27,8 @@ public:
UdpEndpointI(const ProtocolInstancePtr&);
UdpEndpointI(const ProtocolInstancePtr&, Ice::InputStream*);
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
+
virtual Ice::EndpointInfoPtr getInfo() const;
virtual Ice::Int timeout() const;
@@ -46,14 +48,13 @@ public:
virtual bool operator==(const Ice::LocalObject&) const;
virtual bool operator<(const Ice::LocalObject&) const;
#endif
-
+
UdpEndpointIPtr endpoint(const UdpTransceiverPtr&) const;
using IPEndpointI::connectionId;
protected:
- virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual void hashInit(Ice::Int&) const;
virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const;
virtual bool checkOption(const std::string&, const std::string&, const std::string&);
@@ -85,7 +86,7 @@ public:
virtual EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;
+ virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const;
private:
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 998ba5cf58f..4c1c277829f 100644..100755
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -40,11 +40,11 @@ IceInternal::UdpTransceiver::getNativeInfo()
return this;
}
-
-#if defined(ICE_USE_IOCP)
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
AsyncInfo*
IceInternal::UdpTransceiver::getAsyncInfo(SocketOperation status)
{
+#if defined(ICE_USE_IOCP)
switch(status)
{
case SocketOperationRead:
@@ -55,26 +55,9 @@ IceInternal::UdpTransceiver::getAsyncInfo(SocketOperation status)
assert(false);
return 0;
}
-}
#elif defined(ICE_OS_WINRT)
-void
-IceInternal::UdpTransceiver::setCompletedHandler(SocketOperationCompletedHandler^ handler)
-{
- _completedHandler = handler;
- _writeOperationCompletedHandler = ref new AsyncOperationCompletedHandler<unsigned int>(
- [=] (IAsyncOperation<unsigned int>^ operation, Windows::Foundation::AsyncStatus status)
- {
- if(status != Windows::Foundation::AsyncStatus::Completed)
- {
- _write.count = SOCKET_ERROR;
- _write.error = operation->ErrorCode.Value;
- }
- else
- {
- _write.count = static_cast<int>(operation->GetResults());
- }
- _completedHandler(SocketOperationWrite);
- });
+ return &_write;
+#endif
}
#endif
@@ -93,7 +76,15 @@ IceInternal::UdpTransceiver::initialize(Buffer& /*readBuffer*/, Buffer& /*writeB
#elif defined(ICE_OS_WINRT)
if(_write.count == SOCKET_ERROR)
{
- checkConnectErrorCode(__FILE__, __LINE__, _write.error, _addr.host);
+ try
+ {
+ checkConnectErrorCode(__FILE__, __LINE__, _write.error);
+ }
+ catch(Ice::DNSException& ex)
+ {
+ ex.host = IceUtil::wstringToString(_addr.host->RawName->Data(), IceUtil::getProcessStringConverter());
+ throw;
+ }
}
#else
doFinishConnect(_fd);
@@ -124,11 +115,10 @@ IceInternal::UdpTransceiver::close()
if(_readPending)
{
assert(_received.empty());
- _completedHandler(SocketOperationRead);
+ completed(SocketOperationRead);
_readPending = false;
}
_received.clear();
- _completedHandler = nullptr;
#endif
assert(_fd != INVALID_SOCKET);
@@ -394,7 +384,6 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
auto operation = safe_cast<DatagramSocket^>(_fd)->ConnectAsync(_addr.host, _addr.port);
if(!checkIfErrorOrCompleted(SocketOperationConnect, operation))
{
- SocketOperationCompletedHandler^ completed = _completedHandler;
operation->Completed = ref new AsyncActionCompletedHandler(
[=] (IAsyncAction^ info, Windows::Foundation::AsyncStatus status)
{
@@ -422,7 +411,6 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
auto operation = safe_cast<DatagramSocket^>(_fd)->GetOutputStreamAsync(_addr.host, _addr.port);
if(!checkIfErrorOrCompleted(SocketOperationConnect, operation))
{
- SocketOperationCompletedHandler^ completed = _completedHandler;
operation->Completed = ref new AsyncOperationCompletedHandler<IOutputStream^>(
[=] (IAsyncOperation<IOutputStream^>^ info, Windows::Foundation::AsyncStatus status)
{
@@ -456,7 +444,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
}
catch(Platform::Exception^ ex)
{
- checkConnectErrorCode(__FILE__, __LINE__, ex->HResult, _addr.host);
+ checkConnectErrorCode(__FILE__, __LINE__, ex->HResult);
}
return false;
}
@@ -464,7 +452,6 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
{
try
{
- SocketOperationCompletedHandler^ completed = _completedHandler;
DatagramSocket^ fd = safe_cast<DatagramSocket^>(_fd);
concurrency::create_task(fd->GetOutputStreamAsync(_peerAddr.host, _peerAddr.port)).then(
[=,&buf](concurrency::task<IOutputStream^> task)
@@ -474,35 +461,18 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
DataWriter^ writer = ref new DataWriter(task.get());
writer->WriteBytes(ref new Array<unsigned char>(&*buf.i, static_cast<int>(buf.b.size())));
DataWriterStoreOperation^ operation = writer->StoreAsync();
-
- Windows::Foundation::AsyncStatus status = operation->Status;
- if(status == Windows::Foundation::AsyncStatus::Completed)
- {
- //
- // 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
- // completed callback.
- //
- _write.count = operation->GetResults();
- completed(SocketOperationWrite);
- }
- else if(status == Windows::Foundation::AsyncStatus::Started)
- {
- operation->Completed = _writeOperationCompletedHandler;
- }
- else
- {
- if(_state < StateConnected)
- {
- checkConnectErrorCode(__FILE__, __LINE__, operation->ErrorCode.Value, _addr.host);
- }
- else
- {
- checkErrorCode(__FILE__, __LINE__, operation->ErrorCode.Value);
- }
- }
+ if(operation->Status == Windows::Foundation::AsyncStatus::Completed)
+ {
+ //
+ // 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
+ // completed callback.
+ //
+ _write.count = operation->GetResults();
+ }
+ queueOperation(SocketOperationWrite, operation);
}
catch(Platform::Exception^ pex)
{
@@ -523,15 +493,7 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf)
try
{
_writer->WriteBytes(ref new Array<unsigned char>(&*buf.i, static_cast<int>(buf.b.size())));
- DataWriterStoreOperation^ operation = _writer->StoreAsync();
- if(checkIfErrorOrCompleted(SocketOperationWrite, operation))
- {
- _write.count = operation->GetResults();
- }
- else
- {
- operation->Completed = _writeOperationCompletedHandler;
- }
+ queueOperation(SocketOperationWrite, _writer->StoreAsync());
}
catch(Platform::Exception^ ex)
{
@@ -675,7 +637,7 @@ IceInternal::UdpTransceiver::startRead(Buffer& buf)
assert(!_readPending);
if(!_received.empty())
{
- _completedHandler(SocketOperationRead);
+ completed(SocketOperationRead);
}
else
{
@@ -1147,42 +1109,6 @@ IceInternal::UdpTransceiver::setBufSize(int rcvSize, int sndSize)
}
#ifdef ICE_OS_WINRT
-bool
-IceInternal::UdpTransceiver::checkIfErrorOrCompleted(SocketOperation op, IAsyncInfo^ info)
-{
- //
- // NOTE: It's important to only check for info->Status once as it
- // might change during the checks below (the Status can be changed
- // by the Windows thread pool concurrently).
- //
- // We consider that a canceled async status is the same as an
- // error. A canceled async status can occur if there's a timeout
- // and the socket is closed.
- //
- Windows::Foundation::AsyncStatus status = info->Status;
- if(status == Windows::Foundation::AsyncStatus::Completed)
- {
- _completedHandler(op);
- return true;
- }
- else if(status == Windows::Foundation::AsyncStatus::Started)
- {
- return false;
- }
- else
- {
- if(_state < StateConnected)
- {
- checkConnectErrorCode(__FILE__, __LINE__, info->ErrorCode.Value, _addr.host);
- }
- else
- {
- checkErrorCode(__FILE__, __LINE__, info->ErrorCode.Value);
- }
- return true; // Prevent compiler warning.
- }
-}
-
void
IceInternal::UdpTransceiver::appendMessage(DatagramSocketMessageReceivedEventArgs^ args)
{
@@ -1202,7 +1128,7 @@ IceInternal::UdpTransceiver::appendMessage(DatagramSocketMessageReceivedEventArg
//
if(_readPending)
{
- _completedHandler(SocketOperationRead);
+ completed(SocketOperationRead);
_readPending = false;
}
}
diff --git a/cpp/src/Ice/UdpTransceiver.h b/cpp/src/Ice/UdpTransceiver.h
index fc38da8795a..84b600d68c2 100644
--- a/cpp/src/Ice/UdpTransceiver.h
+++ b/cpp/src/Ice/UdpTransceiver.h
@@ -38,10 +38,8 @@ class UdpTransceiver : public Transceiver, public NativeInfo
public:
virtual NativeInfoPtr getNativeInfo();
-#if defined(ICE_USE_IOCP)
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual AsyncInfo* getAsyncInfo(SocketOperation);
-#elif defined(ICE_OS_WINRT)
- virtual void setCompletedHandler(SocketOperationCompletedHandler^);
#endif
virtual SocketOperation initialize(Buffer&, Buffer&);
@@ -80,7 +78,6 @@ private:
void setBufSize(int, int);
#ifdef ICE_OS_WINRT
- bool checkIfErrorOrCompleted(SocketOperation, Windows::Foundation::IAsyncInfo^);
void appendMessage(Windows::Networking::Sockets::DatagramSocketMessageReceivedEventArgs^);
Windows::Networking::Sockets::DatagramSocketMessageReceivedEventArgs^ readMessage();
#endif
@@ -112,12 +109,7 @@ private:
socklen_t _readAddrLen;
#elif defined(ICE_OS_WINRT)
AsyncInfo _write;
-
Windows::Storage::Streams::DataWriter^ _writer;
-
- SocketOperationCompletedHandler^ _completedHandler;
- Windows::Foundation::AsyncOperationCompletedHandler<unsigned int>^ _writeOperationCompletedHandler;
-
IceUtil::Mutex _mutex;
bool _readPending;
std::deque<Windows::Networking::Sockets::DatagramSocketMessageReceivedEventArgs^> _received;
diff --git a/cpp/src/Ice/WSAcceptor.cpp b/cpp/src/Ice/WSAcceptor.cpp
index 2237d6807d7..d72414dae60 100644
--- a/cpp/src/Ice/WSAcceptor.cpp
+++ b/cpp/src/Ice/WSAcceptor.cpp
@@ -21,18 +21,12 @@ IceInternal::WSAcceptor::getNativeInfo()
return _delegate->getNativeInfo();
}
-#if defined(ICE_USE_IOCP)
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
IceInternal::AsyncInfo*
IceInternal::WSAcceptor::getAsyncInfo(IceInternal::SocketOperation status)
{
return _delegate->getNativeInfo()->getAsyncInfo(status);
}
-#elif defined(ICE_OS_WINRT)
-void
-IceInternal::WSAcceptor::setCompletedHandler(IceInternal::SocketOperationCompletedHandler^ handler)
-{
- _delegate->getNativeInfo()->setCompletedHandler(handler);
-}
#endif
void
diff --git a/cpp/src/Ice/WSAcceptor.h b/cpp/src/Ice/WSAcceptor.h
index 8aef5a8ddff..0b389f6a210 100644
--- a/cpp/src/Ice/WSAcceptor.h
+++ b/cpp/src/Ice/WSAcceptor.h
@@ -26,10 +26,8 @@ class WSAcceptor : public Acceptor, public NativeInfo
public:
virtual NativeInfoPtr getNativeInfo();
-#if defined(ICE_USE_IOCP)
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual AsyncInfo* getAsyncInfo(SocketOperation);
-#elif defined(ICE_OS_WINRT)
- virtual void setCompletedHandler(SocketOperationCompletedHandler^);
#endif
virtual void close();
@@ -43,8 +41,6 @@ public:
virtual std::string toString() const;
virtual std::string toDetailedString() const;
- virtual AcceptorPtr delegate() const { return _delegate; }
-
private:
WSAcceptor(const WSEndpointPtr&, const ProtocolInstancePtr&, const AcceptorPtr&);
diff --git a/cpp/src/Ice/WSConnector.cpp b/cpp/src/Ice/WSConnector.cpp
index 91e6a9a7eed..beec5f0ab70 100644
--- a/cpp/src/Ice/WSConnector.cpp
+++ b/cpp/src/Ice/WSConnector.cpp
@@ -19,7 +19,7 @@ using namespace IceInternal;
TransceiverPtr
IceInternal::WSConnector::connect()
{
- return new WSTransceiver(_instance, _delegate->connect(), _host, _port, _resource);
+ return new WSTransceiver(_instance, _delegate->connect(), _host, _resource);
}
Short
@@ -102,9 +102,9 @@ IceInternal::WSConnector::operator<(const Connector& r) const
return false;
}
-IceInternal::WSConnector::WSConnector(const ProtocolInstancePtr& instance, const ConnectorPtr& del, const string& host,
- int port, const string& resource) :
- _instance(instance), _delegate(del), _host(host), _port(port), _resource(resource)
+IceInternal::WSConnector::WSConnector(const ProtocolInstancePtr& instance, const ConnectorPtr& del, const string& host,
+ const string& resource) :
+ _instance(instance), _delegate(del), _host(host), _resource(resource)
{
}
diff --git a/cpp/src/Ice/WSConnector.h b/cpp/src/Ice/WSConnector.h
index 3c26a06ab45..176ec9d770c 100644
--- a/cpp/src/Ice/WSConnector.h
+++ b/cpp/src/Ice/WSConnector.h
@@ -34,15 +34,14 @@ public:
virtual bool operator<(const Connector&) const;
- WSConnector(const ProtocolInstancePtr&, const ConnectorPtr&, const std::string&, int, const std::string&);
+ WSConnector(const ProtocolInstancePtr&, const ConnectorPtr&, const std::string&, const std::string&);
virtual ~WSConnector();
private:
-
+
const ProtocolInstancePtr _instance;
const ConnectorPtr _delegate;
const std::string _host;
- const int _port;
const std::string _resource;
};
diff --git a/cpp/src/Ice/WSEndpoint.cpp b/cpp/src/Ice/WSEndpoint.cpp
index b42f770bc05..48a9ede3c37 100644
--- a/cpp/src/Ice/WSEndpoint.cpp
+++ b/cpp/src/Ice/WSEndpoint.cpp
@@ -22,20 +22,36 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
+namespace
+{
+
+Ice::IPEndpointInfoPtr
+getIPEndpointInfo(const Ice::EndpointInfoPtr& info)
+{
+ for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPEndpointInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
#ifndef ICE_CPP11_MAPPING
IceUtil::Shared* IceInternal::upCast(WSEndpoint* p) { return p; }
#endif
IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& instance, const EndpointIPtr& del, const string& res) :
- _instance(instance),
- _delegate(ICE_DYNAMIC_CAST(IPEndpointI, del)),
- _resource(res)
+ _instance(instance), _delegate(del), _resource(res)
{
}
IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& inst, const EndpointIPtr& del, vector<string>& args) :
- _instance(inst),
- _delegate(ICE_DYNAMIC_CAST(IPEndpointI, del))
+ _instance(inst), _delegate(del)
{
initWithOptions(args);
@@ -46,8 +62,7 @@ IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& inst, const Endpo
}
IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& instance, const EndpointIPtr& del, InputStream* s) :
- _instance(instance),
- _delegate(ICE_DYNAMIC_CAST(IPEndpointI, del))
+ _instance(instance), _delegate(del)
{
s->read(const_cast<string&>(_resource), false);
}
@@ -55,13 +70,12 @@ IceInternal::WSEndpoint::WSEndpoint(const ProtocolInstancePtr& instance, const E
Ice::EndpointInfoPtr
IceInternal::WSEndpoint::getInfo() const
{
-#ifdef ICE_CPP11_MAPPING
- assert(dynamic_pointer_cast<WSEndpointDelegate>(_delegate));
- return dynamic_pointer_cast<WSEndpointDelegate>(_delegate)->getWSInfo(_resource);
-#else
- assert(dynamic_cast<WSEndpointDelegate*>(_delegate.get()));
- return dynamic_cast<WSEndpointDelegate*>(_delegate.get())->getWSInfo(_resource);
-#endif
+ WSEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, shared_from_this());
+ info->underlying = _delegate->getInfo();
+ info->compress = info->underlying->compress;
+ info->timeout = info->underlying->timeout;
+ info->resource = _resource;
+ return info;
}
Ice::Short
@@ -77,12 +91,10 @@ IceInternal::WSEndpoint::protocol() const
}
void
-IceInternal::WSEndpoint::streamWrite(OutputStream* s) const
+IceInternal::WSEndpoint::streamWriteImpl(OutputStream* s) const
{
- s->startEncapsulation();
_delegate->streamWriteImpl(s);
s->write(_resource, false);
- s->endEncapsulation();
}
Int
@@ -169,8 +181,8 @@ IceInternal::WSEndpoint::connectors_async(Ice::EndpointSelectionType selType,
public:
CallbackI(const EndpointI_connectorsPtr& callback, const ProtocolInstancePtr& instance,
- const string& host, int port, const string& resource) :
- _callback(callback), _instance(instance), _host(host), _port(port), _resource(resource)
+ const string& host, const string& resource) :
+ _callback(callback), _instance(instance), _host(host), _resource(resource)
{
}
@@ -179,7 +191,7 @@ IceInternal::WSEndpoint::connectors_async(Ice::EndpointSelectionType selType,
vector<ConnectorPtr> connectors = c;
for(vector<ConnectorPtr>::iterator p = connectors.begin(); p != connectors.end(); ++p)
{
- *p = new WSConnector(_instance, *p, _host, _port, _resource);
+ *p = new WSConnector(_instance, *p, _host, _resource);
}
_callback->connectors(connectors);
}
@@ -194,11 +206,16 @@ IceInternal::WSEndpoint::connectors_async(Ice::EndpointSelectionType selType,
const EndpointI_connectorsPtr _callback;
const ProtocolInstancePtr _instance;
const string _host;
- const int _port;
const string _resource;
};
- _delegate->connectors_async(selType, ICE_MAKE_SHARED(CallbackI, callback, _instance, _delegate->host(),
- _delegate->port(), _resource));
+
+ ostringstream host;
+ IPEndpointInfoPtr info = getIPEndpointInfo(_delegate->getInfo());
+ if(info)
+ {
+ host << info->host << ":" << info->port;
+ }
+ _delegate->connectors_async(selType, ICE_MAKE_SHARED(CallbackI, callback, _instance, host.str(), _resource));
}
AcceptorPtr
@@ -275,12 +292,6 @@ IceInternal::WSEndpoint::options() const
return s.str();
}
-EndpointIPtr
-IceInternal::WSEndpoint::delegate() const
-{
- return ICE_DYNAMIC_CAST(EndpointI, _delegate);
-}
-
bool
#ifdef ICE_CPP11_MAPPING
IceInternal::WSEndpoint::operator==(const Endpoint& r) const
@@ -322,7 +333,7 @@ IceInternal::WSEndpoint::operator<(const Ice::LocalObject& r) const
const WSEndpoint* p = dynamic_cast<const WSEndpoint*>(&r);
if(!p)
{
- const EndpointI* e = dynamic_cast<const WSEndpoint*>(&r);
+ const EndpointI* e = dynamic_cast<const EndpointI*>(&r);
if(!e)
{
return false;
@@ -354,7 +365,6 @@ IceInternal::WSEndpoint::operator<(const Ice::LocalObject& r) const
}
return false;
-
}
bool
@@ -382,8 +392,7 @@ IceInternal::WSEndpoint::checkOption(const string& option, const string& argumen
}
IceInternal::WSEndpointFactory::WSEndpointFactory(const ProtocolInstancePtr& instance, const EndpointFactoryPtr& del) :
- _instance(instance),
- _delegate(del)
+ _instance(instance), _delegate(del)
{
}
@@ -423,8 +432,7 @@ IceInternal::WSEndpointFactory::destroy()
}
EndpointFactoryPtr
-IceInternal::WSEndpointFactory::clone(const ProtocolInstancePtr&) const
+IceInternal::WSEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr& delegate) const
{
- assert(false); // We don't support cloning this transport.
- return 0;
+ return new WSEndpointFactory(instance, delegate);
}
diff --git a/cpp/src/Ice/WSEndpoint.h b/cpp/src/Ice/WSEndpoint.h
index 8216902d3f9..a247219409d 100644
--- a/cpp/src/Ice/WSEndpoint.h
+++ b/cpp/src/Ice/WSEndpoint.h
@@ -20,17 +20,6 @@
namespace IceInternal
{
-//
-// Delegate interface implemented by TcpEndpoint or IceSSL::Endpoint or any endpoint that WS can
-// delegate to.
-//
-class ICE_API WSEndpointDelegate : public virtual IceUtil::Shared
-{
-public:
-
- virtual Ice::EndpointInfoPtr getWSInfo(const std::string&) const = 0;
-};
-
class WSEndpoint : public EndpointI, public Ice::EnableSharedFromThis<WSEndpoint>
{
public:
@@ -39,10 +28,11 @@ public:
WSEndpoint(const ProtocolInstancePtr&, const EndpointIPtr&, std::vector<std::string>&);
WSEndpoint(const ProtocolInstancePtr&, const EndpointIPtr&, Ice::InputStream*);
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
+
virtual Ice::EndpointInfoPtr getInfo() const;
virtual Ice::Short type() const;
virtual const std::string& protocol() const;
- virtual void streamWrite(Ice::OutputStream*) const;
virtual Ice::Int timeout() const;
virtual EndpointIPtr timeout(Ice::Int) const;
@@ -62,7 +52,6 @@ public:
virtual ::Ice::Int hash() const;
virtual std::string options() const;
- EndpointIPtr delegate() const;
WSEndpointPtr endpoint(const EndpointIPtr&) const;
#ifdef ICE_CPP11_MAPPING
@@ -83,7 +72,7 @@ private:
// All members are const, because endpoints are immutable.
//
const ProtocolInstancePtr _instance;
- const IPEndpointIPtr _delegate;
+ const EndpointIPtr _delegate;
const std::string _resource;
};
@@ -100,7 +89,7 @@ public:
virtual EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;
+ virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&, const EndpointFactoryPtr&) const;
private:
diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp
index 5c1b44491ef..24d97b89920 100644
--- a/cpp/src/Ice/WSTransceiver.cpp
+++ b/cpp/src/Ice/WSTransceiver.cpp
@@ -184,18 +184,12 @@ IceInternal::WSTransceiver::getNativeInfo()
return _delegate->getNativeInfo();
}
-#if defined(ICE_USE_IOCP)
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
AsyncInfo*
IceInternal::WSTransceiver::getAsyncInfo(SocketOperation status)
{
return _delegate->getNativeInfo()->getAsyncInfo(status);
}
-#elif defined(ICE_OS_WINRT)
-void
-IceInternal::WSTransceiver::setCompletedHandler(IceInternal::SocketOperationCompletedHandler^ handler)
-{
- _delegate->getNativeInfo()->setCompletedHandler(handler);
-}
#endif
SocketOperation
@@ -236,7 +230,7 @@ IceInternal::WSTransceiver::initialize(Buffer& readBuffer, Buffer& writeBuffer)
//
ostringstream out;
out << "GET " << _resource << " HTTP/1.1\r\n"
- << "Host: " << _host << ":" << _port << "\r\n"
+ << "Host: " << _host << "\r\n"
<< "Upgrade: websocket\r\n"
<< "Connection: Upgrade\r\n"
<< "Sec-WebSocket-Protocol: " << _iceProtocol << "\r\n"
@@ -873,8 +867,10 @@ IceInternal::WSTransceiver::toDetailedString() const
Ice::ConnectionInfoPtr
IceInternal::WSTransceiver::getInfo() const
{
- assert(dynamic_cast<WSTransceiverDelegate*>(_delegate.get()));
- return dynamic_cast<WSTransceiverDelegate*>(_delegate.get())->getWSInfo(_parser->getHeaders());
+ WSConnectionInfoPtr info = ICE_MAKE_SHARED(WSConnectionInfo);
+ info->underlying = _delegate->getInfo();
+ info->headers = _parser->getHeaders();
+ return info;
}
void
@@ -890,11 +886,10 @@ IceInternal::WSTransceiver::setBufferSize(int rcvSize, int sndSize)
}
IceInternal::WSTransceiver::WSTransceiver(const ProtocolInstancePtr& instance, const TransceiverPtr& del,
- const string& host, int port, const string& resource) :
+ const string& host, const string& resource) :
_instance(instance),
_delegate(del),
_host(host),
- _port(port),
_resource(resource),
_incoming(false),
_state(StateInitializeDelegate),
@@ -924,7 +919,6 @@ IceInternal::WSTransceiver::WSTransceiver(const ProtocolInstancePtr& instance, c
IceInternal::WSTransceiver::WSTransceiver(const ProtocolInstancePtr& instance, const TransceiverPtr& del) :
_instance(instance),
_delegate(del),
- _port(-1),
_incoming(true),
_state(StateInitializeDelegate),
_parser(new HttpParser),
diff --git a/cpp/src/Ice/WSTransceiver.h b/cpp/src/Ice/WSTransceiver.h
index db01cd309b8..7b6a7ffe5e6 100644
--- a/cpp/src/Ice/WSTransceiver.h
+++ b/cpp/src/Ice/WSTransceiver.h
@@ -24,26 +24,13 @@ namespace IceInternal
class ConnectorI;
class AcceptorI;
-//
-// Delegate interface implemented by TcpTransceiver or IceSSL::Transceiver or any transport that WS can
-// delegate to.
-//
-class ICE_API WSTransceiverDelegate : public virtual IceUtil::Shared
-{
-public:
-
- virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const = 0;
-};
-
class WSTransceiver : public Transceiver
{
public:
virtual NativeInfoPtr getNativeInfo();
-#if defined(ICE_USE_IOCP)
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual AsyncInfo* getAsyncInfo(SocketOperation);
-#elif defined(ICE_OS_WINRT)
- virtual void setCompletedHandler(SocketOperationCompletedHandler^);
#endif
virtual SocketOperation initialize(Buffer&, Buffer&);
@@ -70,7 +57,7 @@ public:
private:
- WSTransceiver(const ProtocolInstancePtr&, const TransceiverPtr&, const std::string&, int, const std::string&);
+ WSTransceiver(const ProtocolInstancePtr&, const TransceiverPtr&, const std::string&, const std::string&);
WSTransceiver(const ProtocolInstancePtr&, const TransceiverPtr&);
virtual ~WSTransceiver();
@@ -92,7 +79,6 @@ private:
const ProtocolInstancePtr _instance;
const TransceiverPtr _delegate;
const std::string _host;
- const int _port;
const std::string _resource;
const bool _incoming;
diff --git a/cpp/src/Ice/ios/RegisterPluginsInit.cpp b/cpp/src/Ice/ios/RegisterPluginsInit.cpp
deleted file mode 100644
index 712f4dcc765..00000000000
--- a/cpp/src/Ice/ios/RegisterPluginsInit.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#include <Ice/RegisterPluginsInit.h>
-#include <Ice/CommunicatorF.h>
-#include <Ice/Initialize.h>
-
-extern "C"
-{
-
-Ice::Plugin* createIceUDP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
-Ice::Plugin* createIceTCP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
-Ice::Plugin* createIceSSL(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
-Ice::Plugin* createIceIAP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
-
-};
-
-IceInternal::RegisterPluginsInit::RegisterPluginsInit()
-{
- Ice::registerPluginFactory("IceUDP", createIceUDP, true);
- Ice::registerPluginFactory("IceTCP", createIceTCP, true);
- Ice::registerPluginFactory("IceSSL", createIceSSL, true);
- Ice::registerPluginFactory("IceIAP", createIceIAP, true);
-}
diff --git a/cpp/src/Ice/ios/StreamEndpointI.cpp b/cpp/src/Ice/ios/StreamEndpointI.cpp
index cdc59f6a41a..78e8dab2cff 100644
--- a/cpp/src/Ice/ios/StreamEndpointI.cpp
+++ b/cpp/src/Ice/ios/StreamEndpointI.cpp
@@ -23,10 +23,7 @@
#include <Ice/HashUtil.h>
#include <Ice/NetworkProxy.h>
-#include <IceSSL/EndpointInfo.h>
-
#include <CoreFoundation/CoreFoundation.h>
-#include <Security/Security.h>
#include <fstream>
@@ -44,25 +41,10 @@ createIceTCP(const CommunicatorPtr& com, const string&, const StringSeq&)
return new EndpointFactoryPlugin(com, new IceObjC::StreamEndpointFactory(tcpInstance));
}
-Plugin*
-createIceSSL(const CommunicatorPtr& com, const string&, const StringSeq&)
-{
- IceObjC::InstancePtr sslInstance = new IceObjC::Instance(com, SSLEndpointType, "ssl", true);
- return new EndpointFactoryPlugin(com, new IceObjC::StreamEndpointFactory(sslInstance));
-}
-
}
-namespace Ice
-{
-
-void
-registerIceSSL(bool)
+namespace
{
- // Nothing to do, we always register IceSSL
-}
-
-}
inline CFStringRef
toCFString(const string& s)
@@ -70,247 +52,15 @@ toCFString(const string& s)
return CFStringCreateWithCString(NULL, s.c_str(), kCFStringEncodingUTF8);
}
-inline int
-hexValue(char c)
-{
- if(c >= '0' && c <= '9')
- {
- return c - '0';
- }
- else if(c >= 'A' && c <= 'F')
- {
- return (c - 'A') + 10;
- }
- else if(c >= 'a' && c <= 'f')
- {
- return (c - 'a') + 10;
- }
- return -1;
-}
-
-inline CFDataRef
-parseKey(const string& keyStr)
-{
- int i = 0, j = 0;
- const char* m = keyStr.c_str();
- CFMutableDataRef data = CFDataCreateMutable(0, 160);
- unsigned char buf[160];
- while(i < (int)keyStr.size())
- {
- if(isspace(m[i]) || m[i] == ':')
- {
- ++i;
- continue;
- }
- else if(i == (int)keyStr.size() - 1)
- {
- CFRelease(data);
- return 0; // Not enough bytes.
- }
-
- int vh = hexValue(m[i++]);
- int vl = hexValue(m[i++]);
- if(vh < 0 || vl < 0)
- {
- CFRelease(data);
- return 0;
- }
- buf[j] = vh << 4;
- buf[j++] += vl;
-
- if(j == sizeof(buf))
- {
- CFDataAppendBytes(data, (UInt8*)buf, j);
- j = 0;
- }
- }
-
- if(j > 0)
- {
- CFDataAppendBytes(data, buf, j);
- }
-
- return data;
-}
-
-namespace
-{
-
-CFDataRef
-readCert(const string& defaultDir, const string& certFile)
-{
- string path;
- CFURLRef url = 0;
- CFBundleRef bundle = CFBundleGetMainBundle();
- if(bundle)
- {
- CFStringRef resourceName = toCFString(certFile);
- CFStringRef subDirName = toCFString(defaultDir);
- url = CFBundleCopyResourceURL(bundle, resourceName, 0, subDirName);
- CFRelease(resourceName);
- CFRelease(subDirName);
-
- UInt8 filePath[PATH_MAX];
- if(CFURLGetFileSystemRepresentation(url, true, filePath, sizeof(filePath)))
- {
- path = string(reinterpret_cast<char*>(filePath));
- }
- }
-
- if(!url || path.empty())
- {
- path = defaultDir.empty() ? certFile : defaultDir + "/" + certFile;
- }
-
- FILE *file = fopen(path.c_str(), "rb");
- if(!file)
- {
- ostringstream os;
- os << "IceSSL: unable to open file " << certFile << " (error = " << IceUtilInternal::lastErrorToString() << ")";
- throw InitializationException(__FILE__, __LINE__, os.str());
- }
-
- fseek(file, 0, SEEK_END);
- unsigned long size = ftell(file);
- fseek(file, 0, SEEK_SET);
- CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, size);
- CFDataSetLength(data, size);
- if(fread(CFDataGetMutableBytePtr(data), 1, size, file) != size)
- {
- CFRelease(data);
- ostringstream os;
- os << "IceSSL: error while reading file " << certFile;
- throw InitializationException(__FILE__, __LINE__, os.str());
- }
- fclose(file);
- return data;
-}
-
}
IceObjC::Instance::Instance(const Ice::CommunicatorPtr& com, Short type, const string& protocol, bool secure) :
ProtocolInstance(com, type, protocol, secure),
_voip(com->getProperties()->getPropertyAsIntWithDefault("Ice.Voip", 0) > 0),
_communicator(com),
- _serverSettings(0),
- _clientSettings(0),
- _proxySettings(0),
- _certificateAuthorities(0),
- _trustOnlyKeyID(0)
+ _proxySettings(0)
{
const Ice::PropertiesPtr properties = com->getProperties();
- if(secure)
- {
- _clientSettings = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
-
- string defaultDir = properties->getProperty("IceSSL.DefaultDir");
- string certAuthFile = properties->getProperty("IceSSL.CAs");
- if(certAuthFile.empty())
- {
- certAuthFile = properties->getProperty("IceSSL.CertAuthFile");
- }
- string certFile = properties->getProperty("IceSSL.CertFile");
-
- OSStatus err;
- if(!certAuthFile.empty())
- {
- CFDataRef cert = readCert(defaultDir, certAuthFile);
- if(!cert)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unable to open file " + certAuthFile;
- throw ex;
- }
-
- SecCertificateRef result = SecCertificateCreateWithData(0, cert);
- CFRelease(cert);
- if(!result)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: certificate " + certAuthFile + " is not a valid DER-encoded certificate";
- throw ex;
- }
-
- SecCertificateRef certs[] = { result };
- _certificateAuthorities = CFArrayCreate(0, (const void**)certs, 1, &kCFTypeArrayCallBacks);
- CFRelease(result);
-
- // The root CA will be validated by the transceiver.
- // NOTE: on the iPhone, setting kCFStreamSSLAllowsAnyRoot = true isn't enough.
- //CFDictionarySetValue(_clientSettings, kCFStreamSSLAllowsAnyRoot, kCFBooleanTrue);
- CFDictionarySetValue(_clientSettings, kCFStreamSSLValidatesCertificateChain, kCFBooleanFalse);
- }
- else if(properties->getPropertyAsInt("IceSSL.UsePlatformCAs") <= 0)
- {
- // Setup an empty list of Root CAs to not use the system root CAs.
- _certificateAuthorities = CFArrayCreate(0, 0, 0, 0);
- }
-
- if(!certFile.empty())
- {
- CFDataRef cert = readCert(defaultDir, certFile);
- if(!cert)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unable to open file " + certFile;
- throw ex;
- }
-
- CFMutableDictionaryRef settings = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CFStringRef password = toCFString(properties->getProperty("IceSSL.Password"));
- CFDictionarySetValue(settings, kSecImportExportPassphrase, password);
- CFRelease(password);
-
- CFArrayRef items = 0;
- err = SecPKCS12Import(cert, settings, &items);
- CFRelease(cert);
- CFRelease(settings);
- if(err != noErr)
- {
- ostringstream os;
- os << "IceSSL: unable to import certificate from file " << certFile << " (error = " << err << ")";
- throw InitializationException(__FILE__, __LINE__, os.str());
- }
-
- SecIdentityRef identity = 0;
- if(CFArrayGetCount(items) > 0)
- {
- identity = (SecIdentityRef)CFDictionaryGetValue((CFDictionaryRef)CFArrayGetValueAtIndex(items, 0),
- kSecImportItemIdentity);
- }
- if(identity == 0)
- {
- ostringstream os;
- os << "IceSSL: couldn't find identity in file " << certFile << " (error = " << err << ")";
- throw InitializationException(__FILE__, __LINE__, os.str());
- }
- CFRetain(identity);
- CFRelease(items);
-
- SecIdentityRef identities[] = { identity };
- items = CFArrayCreate(0, (const void**)identities, 1, &kCFTypeArrayCallBacks);
- CFDictionarySetValue(_clientSettings, kCFStreamSSLCertificates, items);
- CFRelease(identity);
- CFRelease(items);
- }
-
- string trustOnly = properties->getProperty("IceSSL.TrustOnly.Client");
- if(!trustOnly.empty())
- {
- _trustOnlyKeyID = parseKey(trustOnly);
- if(!_trustOnlyKeyID)
- {
- ostringstream os;
- os << "IceSSL: invalid `IceSSL.TrustOnly.Client' property value";
- throw InitializationException(__FILE__, __LINE__, os.str());
- }
- }
-
- _serverSettings = CFDictionaryCreateMutableCopy(0, 0, _clientSettings);
- CFDictionarySetValue(_serverSettings, kCFStreamSSLIsServer, kCFBooleanTrue);
- }
//
// Proxy settings
@@ -340,22 +90,6 @@ IceObjC::Instance::Instance(const Ice::CommunicatorPtr& com, Short type, const s
IceObjC::Instance::~Instance()
{
- if(_trustOnlyKeyID)
- {
- CFRelease(_trustOnlyKeyID);
- }
- if(_serverSettings)
- {
- CFRelease(_serverSettings);
- }
- if(_clientSettings)
- {
- CFRelease(_clientSettings);
- }
- if(_certificateAuthorities)
- {
- CFRelease(_certificateAuthorities);
- }
if(_proxySettings)
{
CFRelease(_proxySettings);
@@ -387,40 +121,6 @@ IceObjC::Instance::setupStreams(CFReadStreamRef readStream,
throw Ice::SyscallException(__FILE__, __LINE__);
}
}
-
- if(secure())
- {
- CFDictionaryRef settings = server ? _serverSettings : _clientSettings;
-
- if(!CFReadStreamSetProperty(readStream, kCFStreamPropertySocketSecurityLevel,
- kCFStreamSocketSecurityLevelNegotiatedSSL) ||
- !CFWriteStreamSetProperty(writeStream, kCFStreamPropertySocketSecurityLevel,
- kCFStreamSocketSecurityLevelNegotiatedSSL))
- {
- throw Ice::SecurityException(__FILE__, __LINE__, "couldn't set security level");
- }
-
- if(!server && properties()->getPropertyAsIntWithDefault("IceSSL.CheckCertName", 1))
- {
- settings = CFDictionaryCreateMutableCopy(0, 0, settings);
-
- CFStringRef h = toCFString(host);
- CFDictionarySetValue((CFMutableDictionaryRef)settings, kCFStreamSSLPeerName, h);
- CFRelease(h);
- }
- else
- {
- CFRetain(settings);
- }
-
- if(!CFReadStreamSetProperty(readStream, kCFStreamPropertySSLSettings, settings) ||
- !CFWriteStreamSetProperty(writeStream, kCFStreamPropertySSLSettings, settings))
- {
- CFRelease(settings);
- throw Ice::SecurityException(__FILE__, __LINE__, "couldn't set security options");
- }
- CFRelease(settings);
- }
}
IceObjC::Instance*
@@ -459,38 +159,10 @@ IceObjC::StreamEndpointI::StreamEndpointI(const InstancePtr& instance, Ice::Inpu
EndpointInfoPtr
IceObjC::StreamEndpointI::getInfo() const
{
- IPEndpointInfoPtr info;
- if(_instance->secure())
- {
- info = ICE_MAKE_SHARED(InfoI<IceSSL::EndpointInfo>, ICE_DYNAMIC_CAST(StreamEndpointI, shared_from_this()));
- }
- else
- {
- info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, ICE_DYNAMIC_CAST(StreamEndpointI, shared_from_this()));
- }
- fillEndpointInfo(info.get());
- return info;
-}
-
-EndpointInfoPtr
-IceObjC::StreamEndpointI::getWSInfo(const string& resource) const
-{
- IPEndpointInfoPtr info;
- if(_instance->secure())
- {
- IceSSL::WSSEndpointInfoPtr i;
- i = ICE_MAKE_SHARED(InfoI<IceSSL::WSSEndpointInfo>, ICE_DYNAMIC_CAST(StreamEndpointI, shared_from_this()));
- i->resource = resource;
- info = i;
- }
- else
- {
- Ice::WSEndpointInfoPtr i;
- i = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, ICE_DYNAMIC_CAST(StreamEndpointI, shared_from_this()));
- i->resource = resource;
- info = i;
- }
- fillEndpointInfo(info.get());
+ TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, shared_from_this());
+ IPEndpointI::fillEndpointInfo(info.get());
+ info->timeout = _timeout;
+ info->compress = _compress;
return info;
}
@@ -561,7 +233,7 @@ IceObjC::StreamEndpointI::transceiver() const
AcceptorPtr
IceObjC::StreamEndpointI::acceptor(const string&) const
{
- return new StreamAcceptor(ICE_DYNAMIC_CAST(StreamEndpointI, shared_from_this()), _instance, _host, _port);
+ return new StreamAcceptor(shared_from_this(), _instance, _host, _port);
}
IceObjC::StreamEndpointIPtr
@@ -698,14 +370,6 @@ IceObjC::StreamEndpointI::hashInit(Ice::Int& h) const
hashAdd(h, _compress);
}
-void
-IceObjC::StreamEndpointI::fillEndpointInfo(IPEndpointInfo* info) const
-{
- IPEndpointI::fillEndpointInfo(info);
- info->timeout = _timeout;
- info->compress = _compress;
-}
-
bool
IceObjC::StreamEndpointI::checkOption(const string& option, const string& argument, const string& endpoint)
{
@@ -815,7 +479,7 @@ IceObjC::StreamEndpointFactory::destroy()
}
EndpointFactoryPtr
-IceObjC::StreamEndpointFactory::clone(const ProtocolInstancePtr& instance) const
+IceObjC::StreamEndpointFactory::clone(const ProtocolInstancePtr& instance, const EndpointFactoryPtr&) const
{
return new StreamEndpointFactory(_instance->clone(instance));
}
diff --git a/cpp/src/Ice/ios/StreamEndpointI.h b/cpp/src/Ice/ios/StreamEndpointI.h
index 51d3ab75d78..3dd90551199 100644
--- a/cpp/src/Ice/ios/StreamEndpointI.h
+++ b/cpp/src/Ice/ios/StreamEndpointI.h
@@ -37,16 +37,6 @@ public:
Instance(const Ice::CommunicatorPtr&, Ice::Short, const std::string&, bool);
virtual ~Instance();
- CFArrayRef certificateAuthorities() const
- {
- return _certificateAuthorities;
- }
-
- CFDataRef trustOnlyKeyID() const
- {
- return _trustOnlyKeyID;
- }
-
const std::string& proxyHost() const
{
return _proxyHost;
@@ -65,12 +55,7 @@ private:
const bool _voip;
const Ice::CommunicatorPtr _communicator;
- CFMutableDictionaryRef _serverSettings;
- CFMutableDictionaryRef _clientSettings;
CFMutableDictionaryRef _proxySettings;
- CFArrayRef _certificateAuthorities;
- CFDataRef _trustOnlyKeyID;
-
std::string _proxyHost;
int _proxyPort;
};
@@ -86,7 +71,7 @@ typedef ::std::shared_ptr<StreamEndpointI> StreamEndpointIPtr;
typedef IceUtil::Handle<StreamEndpointI> StreamEndpointIPtr;
#endif
-class StreamEndpointI : public IceInternal::IPEndpointI, public IceInternal::WSEndpointDelegate
+class StreamEndpointI : public IceInternal::IPEndpointI, public Ice::EnableSharedFromThis<StreamEndpointI>
{
public:
@@ -96,7 +81,6 @@ public:
StreamEndpointI(const InstancePtr&, Ice::InputStream*);
virtual Ice::EndpointInfoPtr getInfo() const;
- virtual Ice::EndpointInfoPtr getWSInfo(const std::string&) const;
virtual Ice::Int timeout() const;
virtual IceInternal::EndpointIPtr timeout(Ice::Int) const;
@@ -121,12 +105,12 @@ public:
StreamEndpointIPtr endpoint(const StreamAcceptorPtr&) const;
using IPEndpointI::connectionId;
+ using Ice::EnableSharedFromThis<StreamEndpointI>::shared_from_this;
protected:
virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual void hashInit(Ice::Int&) const;
- 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&,
@@ -158,7 +142,8 @@ public:
virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const;
+ virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&,
+ const IceInternal::EndpointFactoryPtr&) const;
private:
diff --git a/cpp/src/Ice/ios/StreamTransceiver.cpp b/cpp/src/Ice/ios/StreamTransceiver.cpp
index bc76ffcd059..4fcbec4f400 100644
--- a/cpp/src/Ice/ios/StreamTransceiver.cpp
+++ b/cpp/src/Ice/ios/StreamTransceiver.cpp
@@ -19,7 +19,6 @@
#include <IceSSL/ConnectionInfo.h>
#include <CoreFoundation/CoreFoundation.h>
-#include <Security/Security.h>
using namespace std;
using namespace Ice;
@@ -292,13 +291,6 @@ IceObjC::StreamTransceiver::initialize(Buffer& readBuffer, Buffer& writeBuffer)
setBlock(_fd, false);
setTcpBufSize(_fd, _instance);
-
- //
- // Limit the size of packets passed to SSLWrite/SSLRead to avoid
- // blocking and holding too much memory.
- //
- _maxSendPacketSize = std::max(512, getSendBufferSize(_fd));
- _maxRecvPacketSize = std::max(512, getRecvBufferSize(_fd));
}
assert(_state == StateConnected);
return SocketOperationNone;
@@ -345,7 +337,7 @@ IceObjC::StreamTransceiver::write(Buffer& buf)
}
// Its impossible for the packetSize to be more than an Int.
- size_t packetSize = std::min(static_cast<size_t>(buf.b.end() - buf.i), _maxSendPacketSize);
+ size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i);
while(buf.i != buf.b.end())
{
if(!CFWriteStreamCanAcceptBytes(_writeStream))
@@ -353,12 +345,6 @@ IceObjC::StreamTransceiver::write(Buffer& buf)
return SocketOperationWrite;
}
- if(_checkCertificates)
- {
- _checkCertificates = false;
- checkCertificates();
- }
-
assert(_fd != INVALID_SOCKET);
CFIndex ret = CFWriteStreamWrite(_writeStream, reinterpret_cast<const UInt8*>(&*buf.i), packetSize);
@@ -401,7 +387,7 @@ IceObjC::StreamTransceiver::read(Buffer& buf)
}
// Its impossible for the packetSize to be more than an Int.
- size_t packetSize = std::min(static_cast<size_t>(buf.b.end() - buf.i), _maxRecvPacketSize);
+ size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i);
while(buf.i != buf.b.end())
{
if(!CFReadStreamHasBytesAvailable(_readStream))
@@ -409,12 +395,6 @@ IceObjC::StreamTransceiver::read(Buffer& buf)
return SocketOperationRead;
}
- if(_checkCertificates)
- {
- _checkCertificates = false;
- checkCertificates();
- }
-
assert(_fd != INVALID_SOCKET);
CFIndex ret = CFReadStreamRead(_readStream, reinterpret_cast<UInt8*>(&*buf.i), packetSize);
@@ -475,39 +455,11 @@ IceObjC::StreamTransceiver::toDetailedString() const
Ice::ConnectionInfoPtr
IceObjC::StreamTransceiver::getInfo() const
{
- if(_instance->secure())
- {
- IceSSL::ConnectionInfoPtr info = ICE_MAKE_SHARED(IceSSL::ConnectionInfo);
- fillConnectionInfo(info);
- info->verified = _state == StateConnected;
- return info;
- }
- else
- {
- Ice::TCPConnectionInfoPtr info = ICE_MAKE_SHARED(Ice::TCPConnectionInfo);
- fillConnectionInfo(info);
- return info;
- }
-}
-
-Ice::ConnectionInfoPtr
-IceObjC::StreamTransceiver::getWSInfo(const Ice::HeaderDict& headers) const
-{
- if(_instance->secure())
- {
- IceSSL::WSSConnectionInfoPtr info = ICE_MAKE_SHARED(IceSSL::WSSConnectionInfo);
- fillConnectionInfo(info);
- info->verified = _state == StateConnected;
- info->headers = headers;
- return info;
- }
- else
- {
- Ice::WSConnectionInfoPtr info = ICE_MAKE_SHARED(Ice::WSConnectionInfo);
- fillConnectionInfo(info);
- info->headers = headers;
- return info;
- }
+ Ice::TCPConnectionInfoPtr info = ICE_MAKE_SHARED(Ice::TCPConnectionInfo);
+ fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort);
+ info->rcvSize = getRecvBufferSize(_fd);
+ info->sndSize = getSendBufferSize(_fd);
+ return info;
}
void
@@ -535,7 +487,6 @@ IceObjC::StreamTransceiver::StreamTransceiver(const InstancePtr& instance,
_readStreamRegistered(false),
_writeStreamRegistered(false),
_opening(false),
- _checkCertificates(instance->secure()),
_error(false),
_state(StateNeedConnect)
{
@@ -562,7 +513,6 @@ IceObjC::StreamTransceiver::StreamTransceiver(const InstancePtr& instance,
_readStreamRegistered(false),
_writeStreamRegistered(false),
_opening(false),
- _checkCertificates(false),
_error(false),
_state(StateNeedConnect),
_desc(fdToString(fd))
@@ -577,144 +527,6 @@ IceObjC::StreamTransceiver::~StreamTransceiver()
}
void
-IceObjC::StreamTransceiver::checkCertificates()
-{
- SecTrustRef trust = (SecTrustRef)CFWriteStreamCopyProperty(_writeStream, kCFStreamPropertySSLPeerTrust);
- if(!trust)
- {
- throw Ice::SecurityException(__FILE__, __LINE__, "unable to obtain trust object");
- }
-
- try
- {
- SecPolicyRef policy = 0;
- if(_host.empty() || _instance->properties()->getPropertyAsIntWithDefault("IceSSL.CheckCertName", 1) == 0)
- {
- policy = SecPolicyCreateBasicX509();
- }
- else
- {
- CFStringRef h = CFStringCreateWithCString(NULL, _host.c_str(), kCFStringEncodingUTF8);
- policy = SecPolicyCreateSSL(false, h);
- CFRelease(h);
- }
-
- OSStatus err = SecTrustSetPolicies(trust, policy);
- CFRelease(policy);
- if(err != noErr)
- {
- ostringstream os;
- os << "unable to set trust object policy (error = " << err << ")";
- throw Ice::SecurityException(__FILE__, __LINE__, os.str());
- }
-
- //
- // If IceSSL.CertAuthFile is set, we use the certificate authorities from this file
- // instead of the ones from the keychain.
- //
- if((err = SecTrustSetAnchorCertificates(trust, _instance->certificateAuthorities())) != noErr)
- {
- ostringstream os;
- os << "couldn't set root CA certificates with trust object (error = " << err << ")";
- throw Ice::SecurityException(__FILE__, __LINE__, os.str());
- }
-
- SecTrustResultType result = kSecTrustResultInvalid;
- if((err = SecTrustEvaluate(trust, &result)) != noErr)
- {
- ostringstream os;
- os << "unable to evaluate the peer certificate trust (error = " << err << ")";
- throw Ice::SecurityException(__FILE__, __LINE__, os.str());
- }
-
- //
- // The kSecTrustResultUnspecified result indicates that the user didn't set any trust
- // settings for the root CA. This is expected if the root CA is provided by the user
- // with IceSSL.CertAuthFile or if the user didn't explicitly set any trust settings
- // for the certificate.
- //
- if(result != kSecTrustResultProceed && result != kSecTrustResultUnspecified)
- {
- ostringstream os;
- os << "certificate validation failed (result = " << result << ")";
- throw Ice::SecurityException(__FILE__, __LINE__, os.str());
- }
-
- if(_instance->trustOnlyKeyID())
- {
- if(SecTrustGetCertificateCount(trust) < 0)
- {
- throw Ice::SecurityException(__FILE__, __LINE__, "unable to obtain peer certificate");
- }
-
- SecCertificateRef cert = SecTrustGetCertificateAtIndex(trust, 0);
-
- //
- // To check the subject key ID, we add the peer certificate to the keychain with SetItemAdd,
- // then we lookup for the cert using the kSecAttrSubjectKeyID. Then we remove the cert from
- // the keychain. NOTE: according to the Apple documentation, it should in theory be possible
- // to not add/remove the item to the keychain by specifying the kSecMatchItemList key (or
- // kSecUseItemList?) when calling SecItemCopyMatching. Unfortunately this doesn't appear to
- // work. Similarly, it should be possible to get back the attributes of the certificate
- // once it added by setting kSecReturnAttributes in the add query, again this doesn't seem
- // to work.
- //
- CFMutableDictionaryRef query;
- query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
- CFDictionarySetValue(query, kSecValueRef, cert);
- err = SecItemAdd(query, 0);
- if(err != noErr && err != errSecDuplicateItem)
- {
- CFRelease(query);
- ostringstream os;
- os << "unable to add peer certificate to keychain (error = " << err << ")";
- throw Ice::SecurityException(__FILE__, __LINE__, os.str());
- }
- CFRelease(query);
-
- query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
- CFDictionarySetValue(query, kSecValueRef, cert);
- CFDictionarySetValue(query, kSecAttrSubjectKeyID, _instance->trustOnlyKeyID());
- err = SecItemCopyMatching(query, 0);
- OSStatus foundErr = err;
- CFRelease(query);
-
- query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
- CFDictionarySetValue(query, kSecValueRef, cert);
- err = SecItemDelete(query);
- if(err != noErr)
- {
- CFRelease(query);
- ostringstream os;
- os << "unable to remove peer certificate from keychain (error = " << err << ")";
- throw Ice::SecurityException(__FILE__, __LINE__, os.str());
- }
- CFRelease(query);
-
- if(foundErr != noErr)
- {
- ostringstream os;
- os << "the certificate subject key ID doesn't match the `IceSSL.TrustOnly.Client' property ";
- os << "(error = " << foundErr << ")";
- throw Ice::SecurityException(__FILE__, __LINE__, os.str());
- }
- }
- CFRelease(trust);
- }
- catch(...)
- {
- if(trust)
- {
- CFRelease(trust);
- }
- throw;
- }
-}
-
-void
IceObjC::StreamTransceiver::checkError(CFErrorRef err, const char* file, int line)
{
assert(err);
@@ -783,11 +595,3 @@ IceObjC::StreamTransceiver::checkError(CFErrorRef err, const char* file, int lin
CFRelease(err);
throw ex;
}
-
-void
-IceObjC::StreamTransceiver::fillConnectionInfo(const Ice::IPConnectionInfoPtr& info) const
-{
- fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort);
- info->rcvSize = getRecvBufferSize(_fd);
- info->sndSize = getSendBufferSize(_fd);
-}
diff --git a/cpp/src/Ice/ios/StreamTransceiver.h b/cpp/src/Ice/ios/StreamTransceiver.h
index 97578f094d0..e38285451f8 100644
--- a/cpp/src/Ice/ios/StreamTransceiver.h
+++ b/cpp/src/Ice/ios/StreamTransceiver.h
@@ -29,8 +29,7 @@ namespace IceObjC
class Instance;
typedef IceUtil::Handle<Instance> InstancePtr;
-class StreamTransceiver : public IceInternal::Transceiver, public IceInternal::StreamNativeInfo,
- public IceInternal::WSTransceiverDelegate
+class StreamTransceiver : public IceInternal::Transceiver, public IceInternal::StreamNativeInfo
{
enum State
{
@@ -67,15 +66,12 @@ public:
virtual std::string toString() const;
virtual std::string toDetailedString() const;
virtual Ice::ConnectionInfoPtr getInfo() const;
- virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const;
virtual void checkSendSize(const IceInternal::Buffer&);
virtual void setBufferSize(int, int);
private:
- void checkCertificates();
void checkError(CFErrorRef, const char*, int);
- void fillConnectionInfo(const Ice::IPConnectionInfoPtr&) const;
const InstancePtr _instance;
const std::string _host;
@@ -85,16 +81,12 @@ private:
bool _readStreamRegistered;
bool _writeStreamRegistered;
bool _opening;
- bool _checkCertificates;
IceUtil::Mutex _mutex;
bool _error;
State _state;
std::string _desc;
-
- size_t _maxSendPacketSize;
- size_t _maxRecvPacketSize;
};
}
diff --git a/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj b/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj
index c6fe7a4255b..68b41ffea80 100644
--- a/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj
+++ b/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
@@ -147,6 +147,7 @@
<ClCompile Include="..\..\..\IceUtil\Shared.cpp" />
<ClCompile Include="..\..\..\IceUtil\StringConverter.cpp" />
<ClCompile Include="..\..\..\IceUtil\StringUtil.cpp" />
+ <ClCompile Include="..\..\StreamSocket.cpp" />
<ClCompile Include="..\..\Thread.cpp" />
<ClCompile Include="..\..\..\IceUtil\ThreadException.cpp" />
<ClCompile Include="..\..\..\IceUtil\Time.cpp" />
@@ -232,10 +233,10 @@
<ClCompile Include="..\..\UdpConnector.cpp" />
<ClCompile Include="..\..\UdpEndpointI.cpp" />
<ClCompile Include="..\..\UdpTransceiver.cpp" />
- <ClCompile Include="..\..\uwp\TcpAcceptor.cpp" />
- <ClCompile Include="..\..\uwp\TcpConnector.cpp" />
- <ClCompile Include="..\..\uwp\TcpEndpointI.cpp" />
- <ClCompile Include="..\..\uwp\TcpTransceiver.cpp" />
+ <ClCompile Include="..\..\TcpAcceptor.cpp" />
+ <ClCompile Include="..\..\TcpConnector.cpp" />
+ <ClCompile Include="..\..\TcpEndpointI.cpp" />
+ <ClCompile Include="..\..\TcpTransceiver.cpp" />
<ClCompile Include="..\..\Value.cpp" />
<ClCompile Include="..\..\ValueFactoryManagerI.cpp" />
<ClCompile Include="..\..\WSAcceptor.cpp" />
@@ -3566,4 +3567,4 @@
<Import Project="$(IceBuilderCppTargets)" Condition="Exists('$(IceBuilderCppTargets)')" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj.filters b/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj.filters
index f6d97e7170b..4a33c8ded78 100644
--- a/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj.filters
+++ b/cpp/src/Ice/msbuild/iceuwp++11/iceuwp++11.vcxproj.filters
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
@@ -319,18 +319,6 @@
<ClCompile Include="..\..\UdpTransceiver.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\uwp\TcpAcceptor.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\uwp\TcpConnector.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\uwp\TcpEndpointI.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\uwp\TcpTransceiver.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\..\RegisterPluginsInit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -1102,6 +1090,19 @@
<ClCompile Include="..\..\Timer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\TcpEndpointI.cpp" />
+ <ClCompile Include="..\..\TcpAcceptor.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\TcpConnector.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\TcpTransceiver.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\StreamSocket.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<IceBuilder Include="..\..\..\..\..\slice\Ice\BuiltinSequences.ice">
@@ -1926,4 +1927,4 @@
<Filter>Header Files\x64\Release</Filter>
</ClInclude>
</ItemGroup>
-</Project>
+</Project> \ No newline at end of file
diff --git a/cpp/src/Ice/uwp/RegisterPluginsInit.cpp b/cpp/src/Ice/uwp/RegisterPluginsInit.cpp
deleted file mode 100644
index c8294ee7033..00000000000
--- a/cpp/src/Ice/uwp/RegisterPluginsInit.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#include <Ice/Initialize.h>
-#include <Ice/RegisterPluginsInit.h>
-
-using namespace std;
-using namespace Ice;
-using namespace IceInternal;
-
-extern "C"
-{
-
-Plugin* createIceUDP(const CommunicatorPtr&, const string&, const StringSeq&);
-Plugin* createIceTCP(const CommunicatorPtr&, const string&, const StringSeq&);
-Plugin* createIceSSL(const CommunicatorPtr&, const string&, const StringSeq&);
-Plugin* createIceDiscovery(const CommunicatorPtr&, const string&, const StringSeq&);
-Plugin* createIceLocatorDiscovery(const CommunicatorPtr&, const string&, const StringSeq&);
-
-}
-
-namespace Ice
-{
-
-void
-registerIceSSL(bool)
-{
- // Nothing to do, IceSSL is always registered by the static initializer.
-}
-
-}
-
-RegisterPluginsInit::RegisterPluginsInit()
-{
- registerPluginFactory("IceUDP", createIceUDP, true);
- registerPluginFactory("IceTCP", createIceTCP, true);
- registerPluginFactory("IceSSL", createIceSSL, true);
- registerPluginFactory("IceDiscovery", createIceDiscovery, false);
- registerPluginFactory("IceLocatorDiscovery", createIceLocatorDiscovery, false);
-}
diff --git a/cpp/src/Ice/uwp/TcpAcceptor.cpp b/cpp/src/Ice/uwp/TcpAcceptor.cpp
deleted file mode 100644
index f97aa28c434..00000000000
--- a/cpp/src/Ice/uwp/TcpAcceptor.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#include <Ice/uwp/TcpAcceptor.h>
-#include <Ice/uwp/TcpTransceiver.h>
-#include <Ice/uwp/TcpEndpointI.h>
-
-#include <Ice/ProtocolInstance.h>
-#include <Ice/LocalException.h>
-#include <Ice/LoggerUtil.h>
-#include <Ice/Exception.h>
-#include <Ice/Properties.h>
-#include <IceUtil/StringUtil.h>
-
-using namespace std;
-using namespace Ice;
-using namespace IceInternal;
-
-using namespace Platform;
-using namespace Windows::Foundation;
-using namespace Windows::Storage::Streams;
-using namespace Windows::Networking;
-using namespace Windows::Networking::Sockets;
-
-IceUtil::Shared* IceInternal::upCast(TcpAcceptor* p) { return p; }
-
-NativeInfoPtr
-IceInternal::TcpAcceptor::getNativeInfo()
-{
- return this;
-}
-
-void
-IceInternal::TcpAcceptor::setCompletedHandler(SocketOperationCompletedHandler^ handler)
-{
- _completedHandler = handler;
-}
-
-void
-IceInternal::TcpAcceptor::close()
-{
- IceUtil::Mutex::Lock lock(_mutex);
- if(_acceptPending)
- {
- assert(_accepted.empty());
- _completedHandler(SocketOperationRead);
- _acceptPending = false;
- }
- else if(!_accepted.empty())
- {
- for(deque<StreamSocket^>::const_iterator p = _accepted.begin(); p != _accepted.end(); ++p)
- {
- closeSocket(*p);
- }
- _accepted.clear();
- }
-
- if(_fd != INVALID_SOCKET)
- {
- closeSocketNoThrow(_fd);
- _fd = INVALID_SOCKET;
- }
-}
-
-EndpointIPtr
-IceInternal::TcpAcceptor::listen()
-{
- try
- {
- const_cast<Address&>(_addr) = doBind(_fd, _addr);
- }
- catch(...)
- {
- _fd = INVALID_SOCKET;
- throw;
- }
- _endpoint = _endpoint->endpoint(this);
- return _endpoint;
-}
-
-void
-IceInternal::TcpAcceptor::startAccept()
-{
- assert(_fd != INVALID_SOCKET);
-
- //
- // If there are already sockets waiting to be accepted, we just
- // notify the selector that the acceptor is ready for acceting the
- // new socket. Otherwise, we set the _acceptPending flag, when a
- // new socket connection event is received, the message handler
- // will notify the selector.
- //
- IceUtil::Mutex::Lock lock(_mutex);
- assert(!_acceptPending);
- if(!_accepted.empty())
- {
- _completedHandler(SocketOperationRead);
- }
- else
- {
- _acceptPending = true;
- }
-}
-
-void
-IceInternal::TcpAcceptor::finishAccept()
-{
- //
- // Nothing to do, we just check there's at least one accepted
- // socket or the acceptor was closed.
- //
- IceUtil::Mutex::Lock lock(_mutex);
- assert(!_acceptPending && (!_accepted.empty() || _fd == INVALID_SOCKET));
-}
-
-TransceiverPtr
-IceInternal::TcpAcceptor::accept()
-{
- if(_fd == INVALID_SOCKET) // Acceptor closed.
- {
- assert(_accepted.empty());
- throw SocketException(__FILE__, __LINE__);
- }
-
- StreamSocket^ fd;
- {
- IceUtil::Mutex::Lock lock(_mutex);
- assert(!_accepted.empty());
- fd = _accepted.front();
- _accepted.pop_front();
- }
-
- return new TcpTransceiver(_instance, fd, true);
-}
-
-string
-IceInternal::TcpAcceptor::protocol() const
-{
- return _instance->protocol();
-}
-
-string
-IceInternal::TcpAcceptor::toString() const
-{
- return addrToString(_addr);
-}
-
-string
-IceInternal::TcpAcceptor::toDetailedString() const
-{
- ostringstream os;
- os << "local address = " << toString();
- vector<string> intfs = getHostsForEndpointExpand(inetAddrToString(_addr), _instance->protocolSupport(), true);
- if(!intfs.empty())
- {
- os << "\nlocal interfaces = ";
- os << IceUtilInternal::joinString(intfs, ", ");
- }
- return os.str();
-}
-
-int
-IceInternal::TcpAcceptor::effectivePort() const
-{
- return getPort(_addr);
-}
-
-IceInternal::TcpAcceptor::TcpAcceptor(const TcpEndpointIPtr& endpoint,
- const ProtocolInstancePtr& instance,
- const string& host,
- int port) :
- _endpoint(endpoint),
- _instance(instance),
- _addr(getAddressForServer(host, port, _instance->protocolSupport(), instance->preferIPv6())),
- _acceptPending(false)
-{
- _fd = ref new StreamSocketListener();
-
- safe_cast<StreamSocketListener^>(_fd)->ConnectionReceived +=
- ref new TypedEventHandler<StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^>(
- [=](StreamSocketListener^, StreamSocketListenerConnectionReceivedEventArgs^ args)
- {
- queueAcceptedSocket(args->Socket);
- });
-}
-
-IceInternal::TcpAcceptor::~TcpAcceptor()
-{
- assert(_fd == INVALID_SOCKET);
-}
-
-void
-IceInternal::TcpAcceptor::queueAcceptedSocket(StreamSocket^ socket)
-{
- IceUtil::Mutex::Lock lock(_mutex);
- if(_fd == INVALID_SOCKET) // Acceptor was closed.
- {
- closeSocket(socket);
- return;
- }
- _accepted.push_back(socket);
-
- //
- // If the acceptor is waiting for a socket to be accepted, notify
- // the selector that the acceptor is ready for "read". This will
- // in turn caused finishAccept() and accept() to be called by the
- // thread pool. If the acceptor isn't ready to accept the socket,
- // it is just queued, when startAccept is called it will be dequed.
- //
- if(_acceptPending)
- {
- _completedHandler(SocketOperationRead);
- _acceptPending = false;
- }
-}
diff --git a/cpp/src/Ice/uwp/TcpAcceptor.h b/cpp/src/Ice/uwp/TcpAcceptor.h
deleted file mode 100644
index bfef0da2712..00000000000
--- a/cpp/src/Ice/uwp/TcpAcceptor.h
+++ /dev/null
@@ -1,65 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef ICE_UWP_TCP_ACCEPTOR_H
-#define ICE_UWP_TCP_ACCEPTOR_H
-
-#include <Ice/TransceiverF.h>
-#include <Ice/ProtocolInstanceF.h>
-#include <Ice/Acceptor.h>
-#include <Ice/Network.h>
-#include <Ice/uwp/TransceiverF.h>
-
-#include <IceUtil/Mutex.h>
-
-#include <deque>
-
-namespace IceInternal
-{
-
-class TcpAcceptor : public Acceptor, public NativeInfo
-{
-public:
-
- virtual NativeInfoPtr getNativeInfo();
- virtual void setCompletedHandler(SocketOperationCompletedHandler^);
-
- virtual void close();
- virtual EndpointIPtr listen();
-
- virtual void startAccept();
- virtual void finishAccept();
-
- virtual TransceiverPtr accept();
- virtual std::string protocol() const;
- virtual std::string toString() const;
- virtual std::string toDetailedString() const;
-
- int effectivePort() const;
-
-private:
-
- TcpAcceptor(const TcpEndpointIPtr&, const ProtocolInstancePtr&, const std::string&, int);
- virtual ~TcpAcceptor();
- friend class TcpEndpointI;
-
- virtual void queueAcceptedSocket(Windows::Networking::Sockets::StreamSocket^);
-
- TcpEndpointIPtr _endpoint;
- const ProtocolInstancePtr _instance;
- const Address _addr;
-
- IceUtil::Mutex _mutex;
- bool _acceptPending;
- SocketOperationCompletedHandler^ _completedHandler;
- std::deque<Windows::Networking::Sockets::StreamSocket^> _accepted;
-};
-
-}
-#endif
diff --git a/cpp/src/Ice/uwp/TcpConnector.cpp b/cpp/src/Ice/uwp/TcpConnector.cpp
deleted file mode 100644
index cba0245497e..00000000000
--- a/cpp/src/Ice/uwp/TcpConnector.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#include <Ice/uwp/TcpConnector.h>
-#include <Ice/uwp/TcpTransceiver.h>
-#include <Ice/uwp/TcpEndpointI.h>
-
-#include <Ice/ProtocolInstance.h>
-#include <Ice/LoggerUtil.h>
-#include <Ice/Network.h>
-#include <Ice/Exception.h>
-
-using namespace std;
-using namespace Ice;
-using namespace IceInternal;
-
-TransceiverPtr
-IceInternal::TcpConnector::connect()
-{
- TransceiverPtr transceiver = new TcpTransceiver(_instance, createSocket(false, _addr), false);
- dynamic_cast<TcpTransceiver*>(transceiver.get())->connect(_addr);
- return transceiver;
-}
-
-Short
-IceInternal::TcpConnector::type() const
-{
- return _instance->type();
-}
-
-string
-IceInternal::TcpConnector::toString() const
-{
- return addrToString(_addr);
-}
-
-bool
-IceInternal::TcpConnector::operator==(const Connector& r) const
-{
- const TcpConnector* p = dynamic_cast<const TcpConnector*>(&r);
- if(!p)
- {
- return false;
- }
-
- if(type() != p->type())
- {
- return false;
- }
-
- if(compareAddress(_addr, p->_addr) != 0)
- {
- return false;
- }
-
- if(_timeout != p->_timeout)
- {
- return false;
- }
-
- if(_connectionId != p->_connectionId)
- {
- return false;
- }
-
- return true;
-}
-
-bool
-IceInternal::TcpConnector::operator!=(const Connector& r) const
-{
- return !operator==(r);
-}
-
-bool
-IceInternal::TcpConnector::operator<(const Connector& r) const
-{
- const TcpConnector* p = dynamic_cast<const TcpConnector*>(&r);
- if(!p)
- {
- return type() < r.type();
- }
-
- if(type() < p->type())
- {
- return true;
- }
- else if(p->type() < type())
- {
- return false;
- }
-
- if(_timeout < p->_timeout)
- {
- return true;
- }
- else if(p->_timeout < _timeout)
- {
- return false;
- }
-
- if(_connectionId < p->_connectionId)
- {
- return true;
- }
- else if(p->_connectionId < _connectionId)
- {
- return false;
- }
- return compareAddress(_addr, p->_addr) < 0;
-}
-
-IceInternal::TcpConnector::TcpConnector(const ProtocolInstancePtr& instance, const Address& addr,
- Ice::Int timeout, const string& connectionId) :
- _instance(instance),
- _addr(addr),
- _timeout(timeout),
- _connectionId(connectionId)
-{
-}
diff --git a/cpp/src/Ice/uwp/TcpConnector.h b/cpp/src/Ice/uwp/TcpConnector.h
deleted file mode 100644
index 96f005de7d0..00000000000
--- a/cpp/src/Ice/uwp/TcpConnector.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef ICE_UWP_TCP_CONNECTOR_H
-#define ICE_UWP_TCP_CONNECTOR_H
-
-#include <Ice/TransceiverF.h>
-#include <Ice/ProtocolInstanceF.h>
-#include <Ice/Connector.h>
-#include <Ice/Network.h>
-
-namespace IceInternal
-{
-
-class TcpConnector : public Connector
-{
-public:
-
- virtual TransceiverPtr connect();
-
- virtual Ice::Short type() const;
- virtual std::string toString() const;
-
- virtual bool operator==(const Connector&) const;
- virtual bool operator!=(const Connector&) const;
- virtual bool operator<(const Connector&) const;
-
-private:
-
- TcpConnector(const ProtocolInstancePtr&, const Address&, Ice::Int, const std::string&);
- friend class TcpEndpointI;
-
- const ProtocolInstancePtr _instance;
- const Address _addr;
- const Ice::Int _timeout;
- const std::string _connectionId;
-};
-
-}
-
-#endif
diff --git a/cpp/src/Ice/uwp/TcpEndpointI.cpp b/cpp/src/Ice/uwp/TcpEndpointI.cpp
deleted file mode 100644
index 020d7283b6f..00000000000
--- a/cpp/src/Ice/uwp/TcpEndpointI.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#include <Ice/uwp/TcpEndpointI.h>
-#include <Ice/uwp/TcpAcceptor.h>
-#include <Ice/uwp/TcpConnector.h>
-#include <Ice/uwp/TcpTransceiver.h>
-
-#include <Ice/Network.h>
-#include <Ice/OutputStream.h>
-#include <Ice/InputStream.h>
-#include <Ice/LocalException.h>
-#include <Ice/ProtocolInstance.h>
-#include <Ice/DefaultsAndOverrides.h>
-#include <Ice/HashUtil.h>
-
-using namespace std;
-using namespace Ice;
-using namespace IceInternal;
-
-extern "C"
-{
-
-Plugin*
-createIceTCP(const CommunicatorPtr& com, const string&, const StringSeq&)
-{
- ProtocolInstancePtr instance = new ProtocolInstance(com, TCPEndpointType, "tcp", false);
- return new EndpointFactoryPlugin(com, new TcpEndpointFactory(instance));
-}
-
-}
-
-#ifndef ICE_CPP11_MAPPING
-IceUtil::Shared* IceInternal::upCast(TcpEndpointI* p) { return p; }
-#endif
-
-IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, const string& ho, Int po, Int ti,
- const string& conId, bool co) :
- IPEndpointI(instance, ho, po, Address(), conId),
- _timeout(ti),
- _compress(co)
-{
-}
-
-IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance) :
- IPEndpointI(instance),
- _timeout(-2),
- _compress(false)
-{
-}
-
-IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, InputStream* s) :
- IPEndpointI(instance, s),
- _timeout(-1),
- _compress(false)
-{
- s->read(const_cast<Int&>(_timeout));
- s->read(const_cast<bool&>(_compress));
-}
-
-EndpointInfoPtr
-IceInternal::TcpEndpointI::getInfo() const
-{
- IPEndpointInfoPtr info;
- info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, shared_from_this());
- fillEndpointInfo(info.get());
- return info;
-}
-
-EndpointInfoPtr
-IceInternal::TcpEndpointI::getWSInfo(const string& resource) const
-{
- IPEndpointInfoPtr info;
- Ice::WSEndpointInfoPtr i = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, shared_from_this());
- i->resource = resource;
- info = i;
- fillEndpointInfo(info.get());
- return info;
-}
-
-Int
-IceInternal::TcpEndpointI::timeout() const
-{
- return _timeout;
-}
-
-EndpointIPtr
-IceInternal::TcpEndpointI::timeout(Int timeout) const
-{
- if(timeout == _timeout)
- {
- return shared_from_this();
- }
- else
- {
- return ICE_MAKE_SHARED(TcpEndpointI, _instance, _host, _port, timeout, _connectionId, _compress);
- }
-}
-
-EndpointIPtr
-IceInternal::TcpEndpointI::connectionId(const string& connectionId) const
-{
- if(connectionId == _connectionId)
- {
- return shared_from_this();
- }
- else
- {
- return ICE_MAKE_SHARED(TcpEndpointI, _instance, _host, _port, _timeout, connectionId, _compress);
- }
-}
-
-bool
-IceInternal::TcpEndpointI::compress() const
-{
- return _compress;
-}
-
-EndpointIPtr
-IceInternal::TcpEndpointI::compress(bool compress) const
-{
- if(compress == _compress)
- {
- return shared_from_this();
- }
- else
- {
- return ICE_MAKE_SHARED(TcpEndpointI, _instance, _host, _port, _timeout, _connectionId, compress);
- }
-}
-
-bool
-IceInternal::TcpEndpointI::datagram() const
-{
- return false;
-}
-
-bool
-IceInternal::TcpEndpointI::secure() const
-{
- return false;
-}
-
-TransceiverPtr
-IceInternal::TcpEndpointI::transceiver() const
-{
- return 0;
-}
-
-AcceptorPtr
-IceInternal::TcpEndpointI::acceptor(const string&) const
-{
- return new TcpAcceptor(ICE_DYNAMIC_CAST(TcpEndpointI, shared_from_this()), _instance, _host, _port);
-}
-
-TcpEndpointIPtr
-IceInternal::TcpEndpointI::endpoint(const TcpAcceptorPtr& acceptor) const
-{
- return ICE_MAKE_SHARED(TcpEndpointI, _instance, _host, acceptor->effectivePort(), _timeout, _connectionId, _compress);
-}
-
-string
-IceInternal::TcpEndpointI::options() const
-{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
- ostringstream s;
-
- s << IPEndpointI::options();
-
- if(_timeout == -1)
- {
- s << " -t infinite";
- }
- else
- {
- s << " -t " << _timeout;
- }
-
- if(_compress)
- {
- s << " -z";
- }
-
- return s.str();
-}
-
-bool
-#ifdef ICE_CPP11_MAPPING
-IceInternal::TcpEndpointI::operator==(const Endpoint& r) const
-#else
-IceInternal::TcpEndpointI::operator==(const LocalObject& r) const
-#endif
-{
- if(!IPEndpointI::operator==(r))
- {
- return false;
- }
-
- const TcpEndpointI* p = dynamic_cast<const TcpEndpointI*>(&r);
- if(!p)
- {
- return false;
- }
-
- if(this == p)
- {
- return true;
- }
-
- if(_timeout != p->_timeout)
- {
- return false;
- }
-
- if(_compress != p->_compress)
- {
- return false;
- }
-
- return true;
-}
-
-bool
-#ifdef ICE_CPP11_MAPPING
-IceInternal::TcpEndpointI::operator<(const Endpoint& r) const
-#else
-IceInternal::TcpEndpointI::operator<(const LocalObject& r) const
-#endif
-{
- const TcpEndpointI* p = dynamic_cast<const TcpEndpointI*>(&r);
- if(!p)
- {
- const EndpointI* e = dynamic_cast<const EndpointI*>(&r);
- if(!e)
- {
- return false;
- }
- return type() < e->type();
- }
-
- if(this == p)
- {
- return false;
- }
-
- if(_timeout < p->_timeout)
- {
- return true;
- }
- else if(p->_timeout < _timeout)
- {
- return false;
- }
-
- if(!_compress && p->_compress)
- {
- return true;
- }
- else if(p->_compress < _compress)
- {
- return false;
- }
-
- return IPEndpointI::operator<(r);
-}
-
-void
-IceInternal::TcpEndpointI::streamWriteImpl(OutputStream* s) const
-{
- IPEndpointI::streamWriteImpl(s);
- s->write(_timeout);
- s->write(_compress);
-}
-
-void
-IceInternal::TcpEndpointI::hashInit(Ice::Int& h) const
-{
- IPEndpointI::hashInit(h);
- hashAdd(h, _timeout);
- hashAdd(h, _compress);
-}
-
-void
-IceInternal::TcpEndpointI::fillEndpointInfo(IPEndpointInfo* info) const
-{
- IPEndpointI::fillEndpointInfo(info);
- info->timeout = _timeout;
- info->compress = _compress;
-}
-
-void
-IceInternal::TcpEndpointI::initWithOptions(vector<string>& args, bool oaEndpoint)
-{
- IPEndpointI::initWithOptions(args, oaEndpoint);
-
- if(_timeout == -2)
- {
- const_cast<Int&>(_timeout) = _instance->defaultTimeout();
- }
-}
-
-bool
-IceInternal::TcpEndpointI::checkOption(const string& option, const string& argument, const string& endpoint)
-{
- if(IPEndpointI::checkOption(option, argument, endpoint))
- {
- return true;
- }
-
- switch(option[1])
- {
- case 't':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "no argument provided for -t option in endpoint " + endpoint;
- throw ex;
- }
-
- if(argument == "infinite")
- {
- const_cast<Int&>(_timeout) = -1;
- }
- else
- {
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
- throw ex;
- }
- }
- return true;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- return true;
- }
-
- default:
- {
- return false;
- }
- }
-}
-
-ConnectorPtr
-IceInternal::TcpEndpointI::createConnector(const Address& address, const NetworkProxyPtr& proxy) const
-{
- // TODO: Add support for network proxies?
- return new TcpConnector(_instance, address, _timeout, _connectionId);
-}
-
-IPEndpointIPtr
-IceInternal::TcpEndpointI::createEndpoint(const string& host, int port, const string& connectionId) const
-{
- return ICE_MAKE_SHARED(TcpEndpointI, _instance, host, port, _timeout, connectionId, _compress);
-}
-
-IceInternal::TcpEndpointFactory::TcpEndpointFactory(const ProtocolInstancePtr& instance) : _instance(instance)
-{
-}
-
-IceInternal::TcpEndpointFactory::~TcpEndpointFactory()
-{
-}
-
-Short
-IceInternal::TcpEndpointFactory::type() const
-{
- return _instance->type();
-}
-
-string
-IceInternal::TcpEndpointFactory::protocol() const
-{
- return _instance->protocol();
-}
-
-EndpointIPtr
-IceInternal::TcpEndpointFactory::create(vector<string>& args, bool oaEndpoint) const
-{
- IPEndpointIPtr endpt = ICE_MAKE_SHARED(TcpEndpointI, _instance);
- endpt->initWithOptions(args, oaEndpoint);
- return endpt;
-}
-
-EndpointIPtr
-IceInternal::TcpEndpointFactory::read(InputStream* s) const
-{
- return ICE_MAKE_SHARED(TcpEndpointI, _instance, s);
-}
-
-void
-IceInternal::TcpEndpointFactory::destroy()
-{
- _instance = 0;
-}
-
-EndpointFactoryPtr
-IceInternal::TcpEndpointFactory::clone(const ProtocolInstancePtr& instance) const
-{
- return new TcpEndpointFactory(instance);
-}
diff --git a/cpp/src/Ice/uwp/TcpEndpointI.h b/cpp/src/Ice/uwp/TcpEndpointI.h
deleted file mode 100644
index 19a40eac4e5..00000000000
--- a/cpp/src/Ice/uwp/TcpEndpointI.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef ICE_UWP_TCP_ENDPOINT_I_H
-#define ICE_UWP_TCP_ENDPOINT_I_H
-
-#include <IceUtil/Config.h>
-#include <Ice/IPEndpointI.h>
-#include <Ice/EndpointFactory.h>
-#include <Ice/WSEndpoint.h>
-#include <Ice/Network.h> // for IceIternal::Address
-#include <Ice/uwp/TransceiverF.h>
-
-namespace IceInternal
-{
-
-class TcpEndpointI : public IPEndpointI, public WSEndpointDelegate
-{
-public:
-
- TcpEndpointI(const ProtocolInstancePtr&, const std::string&, Ice::Int, Ice::Int, const std::string&, bool);
- TcpEndpointI(const ProtocolInstancePtr&);
- TcpEndpointI(const ProtocolInstancePtr&, Ice::InputStream*);
-
- virtual Ice::EndpointInfoPtr getInfo() const;
- virtual Ice::EndpointInfoPtr getWSInfo(const std::string&) const;
-
- virtual Ice::Int timeout() const;
- virtual EndpointIPtr timeout(Ice::Int) const;
- virtual EndpointIPtr connectionId(const ::std::string&) const;
- virtual bool compress() const;
- virtual EndpointIPtr compress(bool) const;
- virtual bool datagram() const;
- virtual bool secure() const;
-
- virtual TransceiverPtr transceiver() const;
- virtual AcceptorPtr acceptor(const std::string&) const;
- virtual std::string options() const;
-
-#ifdef ICE_CPP11_MAPPING
- virtual bool operator==(const Ice::Endpoint&) const;
- virtual bool operator<(const Ice::Endpoint&) const;
-#else
- virtual bool operator==(const Ice::LocalObject&) const;
- virtual bool operator<(const Ice::LocalObject&) const;
-#endif
-
- TcpEndpointIPtr endpoint(const TcpAcceptorPtr&) const;
-
- using IPEndpointI::connectionId;
-
-protected:
-
- virtual void streamWriteImpl(Ice::OutputStream*) const;
- virtual void hashInit(Ice::Int&) const;
- virtual void initWithOptions(std::vector<std::string>&, bool);
- virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const;
- virtual bool checkOption(const std::string&, const std::string&, const std::string&);
-
- virtual ConnectorPtr createConnector(const Address&, const NetworkProxyPtr&) const;
- virtual IPEndpointIPtr createEndpoint(const std::string&, int, const std::string&) const;
-
-private:
-
- //
- // All members are const, because endpoints are immutable.
- //
- const Ice::Int _timeout;
- const bool _compress;
-};
-
-class TcpEndpointFactory : public EndpointFactory
-{
-public:
-
- TcpEndpointFactory(const ProtocolInstancePtr&);
- virtual ~TcpEndpointFactory();
-
- virtual Ice::Short type() const;
- virtual std::string protocol() const;
- virtual EndpointIPtr create(std::vector<std::string>&, bool) const;
- virtual EndpointIPtr read(Ice::InputStream*) const;
- virtual void destroy();
-
- virtual EndpointFactoryPtr clone(const ProtocolInstancePtr&) const;
-
-private:
-
- ProtocolInstancePtr _instance;
-};
-
-}
-
-#endif
diff --git a/cpp/src/Ice/uwp/TcpTransceiver.cpp b/cpp/src/Ice/uwp/TcpTransceiver.cpp
deleted file mode 100644
index de400168fa3..00000000000
--- a/cpp/src/Ice/uwp/TcpTransceiver.cpp
+++ /dev/null
@@ -1,399 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#include <Ice/uwp/TcpTransceiver.h>
-#include <Ice/Connection.h>
-#include <Ice/ProtocolInstance.h>
-#include <Ice/LoggerUtil.h>
-#include <Ice/Buffer.h>
-#include <Ice/LocalException.h>
-#include <Ice/Properties.h>
-
-using namespace std;
-using namespace Ice;
-using namespace IceInternal;
-
-using namespace Platform;
-using namespace Windows::Foundation;
-using namespace Windows::Storage::Streams;
-using namespace Windows::Networking;
-using namespace Windows::Networking::Sockets;
-
-namespace
-{
-
-AsyncOperationCompletedHandler<unsigned int>^
-createAsyncOperationCompletedHandler(SocketOperationCompletedHandler^ cb, SocketOperation op, AsyncInfo& info)
-{
- return ref new AsyncOperationCompletedHandler<unsigned int>(
- [=,&info] (IAsyncOperation<unsigned int>^ operation, Windows::Foundation::AsyncStatus status)
- {
- if(status != Windows::Foundation::AsyncStatus::Completed)
- {
- info.count = SOCKET_ERROR;
- info.error = operation->ErrorCode.Value;
- }
- else
- {
- info.count = static_cast<int>(operation->GetResults());
- }
- cb(op);
- });
-}
-
-}
-
-NativeInfoPtr
-IceInternal::TcpTransceiver::getNativeInfo()
-{
- return this;
-}
-
-void
-IceInternal::TcpTransceiver::setCompletedHandler(SocketOperationCompletedHandler^ handler)
-{
- _completedHandler = handler;
- _readOperationCompletedHandler = createAsyncOperationCompletedHandler(handler, SocketOperationRead, _read);
- _writeOperationCompletedHandler = createAsyncOperationCompletedHandler(handler, SocketOperationWrite, _write);
-}
-
-SocketOperation
-IceInternal::TcpTransceiver::initialize(Buffer&, Buffer&)
-{
- if(_state == StateNeedConnect)
- {
- _state = StateConnectPending;
- return SocketOperationConnect;
- }
- else if(_state <= StateConnectPending)
- {
- if(_write.count == SOCKET_ERROR)
- {
- checkConnectErrorCode(__FILE__, __LINE__, _write.error, _connectAddr.host);
- }
- _state = StateConnected;
- _desc = fdToString(_fd);
- }
- assert(_state == StateConnected);
- return SocketOperationNone;
-}
-
-SocketOperation
-#ifdef ICE_CPP11_MAPPING
-IceInternal::TcpTransceiver::closing(bool initiator, exception_ptr)
-#else
-IceInternal::TcpTransceiver::closing(bool initiator, const Ice::LocalException&)
-#endif
-{
- // If we are initiating the connection closure, wait for the peer
- // to close the TCP/IP connection. Otherwise, close immediately.
- return initiator ? SocketOperationRead : SocketOperationNone;
-}
-
-void
-IceInternal::TcpTransceiver::close()
-{
- assert(_fd != INVALID_SOCKET);
-
- _completedHandler = nullptr;
- _readOperationCompletedHandler = nullptr;
- _writeOperationCompletedHandler = nullptr;
-
- try
- {
- closeSocket(_fd);
- _fd = INVALID_SOCKET;
- }
- catch(const SocketException&)
- {
- _fd = INVALID_SOCKET;
- throw;
- }
-}
-
-SocketOperation
-IceInternal::TcpTransceiver::write(Buffer& buf)
-{
- return buf.i == buf.b.end() ? SocketOperationNone : SocketOperationWrite;
-}
-
-SocketOperation
-IceInternal::TcpTransceiver::read(Buffer& buf)
-{
- return buf.i == buf.b.end() ? SocketOperationNone : SocketOperationRead;
-}
-
-bool
-IceInternal::TcpTransceiver::startWrite(Buffer& buf)
-{
- if(_state < StateConnected)
- {
- try
- {
- IAsyncAction^ action = safe_cast<StreamSocket^>(_fd)->ConnectAsync(
- _connectAddr.host,
- _connectAddr.port,
- SocketProtectionLevel::PlainSocket);
-
- if(!checkIfErrorOrCompleted(SocketOperationConnect, action))
- {
- SocketOperationCompletedHandler^ completed = _completedHandler;
- action->Completed = ref new AsyncActionCompletedHandler(
- [=] (IAsyncAction^ info, Windows::Foundation::AsyncStatus status)
- {
- if(status != Windows::Foundation::AsyncStatus::Completed)
- {
- _write.count = SOCKET_ERROR;
- _write.error = info->ErrorCode.Value;
- }
- else
- {
- _write.count = 0;
- }
- completed(SocketOperationConnect);
- });
- }
- }
- catch(Platform::Exception^ ex)
- {
- checkConnectErrorCode(__FILE__, __LINE__, ex->HResult, _connectAddr.host);
- }
- return false;
- }
-
- assert(!buf.b.empty());
- assert(buf.i != buf.b.end());
-
- int packetSize = static_cast<int>(buf.b.end() - buf.i);
- if(_maxSendPacketSize > 0 && packetSize > _maxSendPacketSize)
- {
- packetSize = _maxSendPacketSize;
- }
- assert(packetSize > 0);
- _writer->WriteBytes(ref new Array<unsigned char>(&*buf.i, packetSize));
- try
- {
- DataWriterStoreOperation^ operation = _writer->StoreAsync();
- if(checkIfErrorOrCompleted(SocketOperationWrite, operation))
- {
- _write.count = operation->GetResults();
- }
- else
- {
- operation->Completed = _writeOperationCompletedHandler;
- }
- }
- catch(Platform::Exception^ ex)
- {
- checkErrorCode(__FILE__, __LINE__, ex->HResult);
- }
- return packetSize == static_cast<int>(buf.b.end() - buf.i);
-}
-
-void
-IceInternal::TcpTransceiver::finishWrite(Buffer& buf)
-{
- if(_state < StateConnected)
- {
- if(_write.count == SOCKET_ERROR)
- {
- checkConnectErrorCode(__FILE__, __LINE__, _write.error, _connectAddr.host);
- }
- _verified = true;
- return;
- }
-
- if(_write.count == SOCKET_ERROR)
- {
- checkErrorCode(__FILE__, __LINE__, _write.error);
- }
-
- buf.i += _write.count;
-}
-
-void
-IceInternal::TcpTransceiver::startRead(Buffer& buf)
-{
- int packetSize = static_cast<int>(buf.b.end() - buf.i);
- if(_maxReceivePacketSize > 0 && packetSize > _maxReceivePacketSize)
- {
- packetSize = _maxReceivePacketSize;
- }
- assert(!buf.b.empty() && buf.i != buf.b.end());
-
- try
- {
- DataReaderLoadOperation^ operation = _reader->LoadAsync(packetSize);
- if(checkIfErrorOrCompleted(SocketOperationRead, operation))
- {
- _read.count = operation->GetResults();
- }
- else
- {
- operation->Completed = _readOperationCompletedHandler;
- }
- }
- catch(Platform::Exception^ ex)
- {
- checkErrorCode(__FILE__, __LINE__, ex->HResult);
- }
-}
-
-void
-IceInternal::TcpTransceiver::finishRead(Buffer& buf)
-{
- if(_read.count == SOCKET_ERROR)
- {
- checkErrorCode(__FILE__, __LINE__, _read.error);
- }
- else if(_read.count == 0)
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
- }
-
- try
- {
- auto data = ref new Platform::Array<unsigned char>(_read.count);
- _reader->ReadBytes(data);
- memcpy(&*buf.i, data->Data, _read.count);
- }
- catch(Platform::Exception^ ex)
- {
- checkErrorCode(__FILE__, __LINE__, ex->HResult);
- }
-
- buf.i += _read.count;
-}
-
-string
-IceInternal::TcpTransceiver::protocol() const
-{
- return _instance->protocol();
-}
-
-string
-IceInternal::TcpTransceiver::toString() const
-{
- return _desc;
-}
-
-string
-IceInternal::TcpTransceiver::toDetailedString() const
-{
- return toString();
-}
-
-Ice::ConnectionInfoPtr
-IceInternal::TcpTransceiver::getInfo() const
-{
- Ice::IPConnectionInfoPtr info;
- info = ICE_MAKE_SHARED(Ice::TCPConnectionInfo);
- fillConnectionInfo(info);
- return info;
-}
-
-Ice::ConnectionInfoPtr
-IceInternal::TcpTransceiver::getWSInfo(const Ice::HeaderDict& headers) const
-{
- Ice::WSConnectionInfoPtr info = ICE_MAKE_SHARED(Ice::WSConnectionInfo);
- fillConnectionInfo(info);
- info->headers = headers;
- return info;
-}
-
-void
-IceInternal::TcpTransceiver::checkSendSize(const Buffer&)
-{
-}
-
- void
- IceInternal::TcpTransceiver::setBufferSize(int rcvSize, int sndSize)
- {
- setTcpBufSize(_fd, rcvSize, sndSize, _instance);
- }
-
-IceInternal::TcpTransceiver::TcpTransceiver(const ProtocolInstancePtr& instance, SOCKET fd, bool connected) :
- NativeInfo(fd),
- _instance(instance),
- _state(connected ? StateConnected : StateNeedConnect),
- _desc(connected ? fdToString(_fd) : string()),
- _verified(false)
-{
- StreamSocket^ streamSocket = safe_cast<StreamSocket^>(_fd);
- _writer = ref new DataWriter(streamSocket->OutputStream);
- _reader = ref new DataReader(streamSocket->InputStream);
- _reader->InputStreamOptions = InputStreamOptions::Partial;
-
- setTcpBufSize(_fd, _instance);
-
- _maxSendPacketSize = streamSocket->Control->OutboundBufferSizeInBytes / 2;
- if(_maxSendPacketSize < 512)
- {
- _maxSendPacketSize = 0;
- }
-
- _maxReceivePacketSize = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.RcvSize", 128 * 1024);
-}
-
-IceInternal::TcpTransceiver::~TcpTransceiver()
-{
- assert(_fd == INVALID_SOCKET);
-}
-
-void
-IceInternal::TcpTransceiver::connect(const Address& addr)
-{
- _connectAddr = addr;
-}
-
-bool
-IceInternal::TcpTransceiver::checkIfErrorOrCompleted(SocketOperation op, IAsyncInfo^ info, int count)
-{
- //
- // NOTE: It's important to only check for info->Status once as it
- // might change during the checks below (the Status can be changed
- // by the Windows thread pool concurrently).
- //
- // We consider that a canceled async status is the same as an
- // error. A canceled async status can occur if there's a timeout
- // and the socket is closed.
- //
- Windows::Foundation::AsyncStatus status = info->Status;
- if(status == Windows::Foundation::AsyncStatus::Completed)
- {
- _completedHandler(op);
- return true;
- }
- else if (status == Windows::Foundation::AsyncStatus::Started)
- {
- return false;
- }
- else
- {
- if(_state < StateConnected)
- {
- checkConnectErrorCode(__FILE__, __LINE__, info->ErrorCode.Value, _connectAddr.host);
- }
- else
- {
- checkErrorCode(__FILE__, __LINE__, info->ErrorCode.Value);
- }
- return true; // Prevent compiler warning.
- }
-}
-
-void
-IceInternal::TcpTransceiver::fillConnectionInfo(const Ice::IPConnectionInfoPtr& info) const
-{
- fdToAddressAndPort(_fd, info->localAddress, info->localPort, info->remoteAddress, info->remotePort);
- info->rcvSize = getRecvBufferSize(_fd);
- info->sndSize = getSendBufferSize(_fd);
-}
diff --git a/cpp/src/Ice/uwp/TcpTransceiver.h b/cpp/src/Ice/uwp/TcpTransceiver.h
deleted file mode 100644
index 433da311100..00000000000
--- a/cpp/src/Ice/uwp/TcpTransceiver.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef ICE_UWP_TCP_TRANSCEIVER_H
-#define ICE_UWP_TCP_TRANSCEIVER_H
-
-#include <Ice/ProtocolInstanceF.h>
-#include <Ice/Transceiver.h>
-#include <Ice/Network.h>
-#include <Ice/WSTransceiver.h>
-
-namespace IceInternal
-{
-
-class StreamConnector;
-class StreamAcceptor;
-
-class TcpTransceiver : public Transceiver, public NativeInfo, public WSTransceiverDelegate
-{
- enum State
- {
- StateNeedConnect,
- StateConnectPending,
- StateConnected
- };
-
-public:
-
- virtual NativeInfoPtr getNativeInfo();
- virtual void setCompletedHandler(SocketOperationCompletedHandler^);
-
- virtual SocketOperation initialize(Buffer&, Buffer&);
-#ifdef ICE_CPP11_MAPPING
- virtual SocketOperation closing(bool, std::exception_ptr);
-#else
- virtual SocketOperation closing(bool, const Ice::LocalException&);
-#endif
- virtual void close();
- virtual SocketOperation write(Buffer&);
- virtual SocketOperation read(Buffer&);
-
- virtual bool startWrite(Buffer&);
- virtual void finishWrite(Buffer&);
- virtual void startRead(Buffer&);
- virtual void finishRead(Buffer&);
-
- virtual std::string protocol() const;
- virtual std::string toString() const;
- virtual std::string toDetailedString() const;
- virtual Ice::ConnectionInfoPtr getInfo() const;
- virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const;
- virtual void checkSendSize(const Buffer&);
- virtual void setBufferSize(int rcvSize, int sndSize);
-
-private:
-
- TcpTransceiver(const ProtocolInstancePtr&, SOCKET, bool);
- virtual ~TcpTransceiver();
-
- void connect(const Address&);
- bool checkIfErrorOrCompleted(SocketOperation, Windows::Foundation::IAsyncInfo^, int = 0);
- void fillConnectionInfo(const Ice::IPConnectionInfoPtr&) const;
-
- friend class TcpConnector;
- friend class TcpAcceptor;
-
- const ProtocolInstancePtr _instance;
-
- State _state;
- std::string _desc;
- bool _verified;
- Address _connectAddr;
-
- AsyncInfo _read;
- AsyncInfo _write;
- int _maxSendPacketSize;
- int _maxReceivePacketSize;
-
- Windows::Storage::Streams::DataReader^ _reader;
- Windows::Storage::Streams::DataWriter^ _writer;
-
- Windows::Foundation::AsyncOperationCompletedHandler<unsigned int>^ _readOperationCompletedHandler;
- Windows::Foundation::AsyncOperationCompletedHandler<unsigned int>^ _writeOperationCompletedHandler;
-};
-
-}
-
-#endif
diff --git a/cpp/src/Ice/uwp/TransceiverF.h b/cpp/src/Ice/uwp/TransceiverF.h
deleted file mode 100644
index 76572a71a66..00000000000
--- a/cpp/src/Ice/uwp/TransceiverF.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-#ifndef ICE_UWP_TRANSCEIVER_F_H
-#define ICE_UWP_TRANSCEIVER_F_H
-
-#include <IceUtil/Shared.h>
-#include <Ice/Handle.h>
-
-namespace IceInternal
-{
-
-class TcpEndpointI;
-#ifndef ICE_CPP11_MAPPING
-ICE_API IceUtil::Shared* upCast(TcpEndpointI*);
-#endif
-ICE_DEFINE_PTR(TcpEndpointIPtr, TcpEndpointI);
-
-class TcpAcceptor;
-ICE_API IceUtil::Shared* upCast(TcpAcceptor*);
-typedef IceInternal::Handle<TcpAcceptor> TcpAcceptorPtr;
-
-}
-
-#endif
diff --git a/cpp/src/IceBT/EndpointI.cpp b/cpp/src/IceBT/EndpointI.cpp
index 1f4ab9a99da..5c0d31cc8ef 100644
--- a/cpp/src/IceBT/EndpointI.cpp
+++ b/cpp/src/IceBT/EndpointI.cpp
@@ -92,17 +92,15 @@ IceBT::EndpointI::EndpointI(const InstancePtr& instance, InputStream* s) :
}
void
-IceBT::EndpointI::streamWrite(OutputStream* s) const
+IceBT::EndpointI::streamWriteImpl(OutputStream* s) const
{
//
// _name and _channel are not marshaled.
//
- s->startEncapsulation();
s->write(_addr, false);
s->write(_uuid, false);
s->write(_timeout);
s->write(_compress);
- s->endEncapsulation();
}
Ice::Short
@@ -758,7 +756,8 @@ IceBT::EndpointFactoryI::destroy()
}
IceInternal::EndpointFactoryPtr
-IceBT::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& instance) const
+IceBT::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& instance,
+ const IceInternal::EndpointFactoryPtr&) const
{
return new EndpointFactoryI(new Instance(_instance->engine(), instance->type(), instance->protocol()));
}
diff --git a/cpp/src/IceBT/EndpointI.h b/cpp/src/IceBT/EndpointI.h
index d3034413567..f0d2433d122 100644
--- a/cpp/src/IceBT/EndpointI.h
+++ b/cpp/src/IceBT/EndpointI.h
@@ -30,7 +30,7 @@ public:
EndpointI(const InstancePtr&);
EndpointI(const InstancePtr&, Ice::InputStream*);
- virtual void streamWrite(Ice::OutputStream*) const;
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual Ice::Short type() const;
virtual const std::string& protocol() const;
virtual Ice::Int timeout() const;
@@ -49,7 +49,7 @@ public:
#ifdef ICE_CPP11_MAPPING
virtual bool operator==(const Ice::Endpoint&) const;
- virtual bool operator<(const Ice::Endpoint&) const;
+ virtual bool operator<(const Ice::Endpoint&) const;
#else
virtual bool operator==(const Ice::LocalObject&) const;
virtual bool operator<(const Ice::LocalObject&) const;
@@ -140,7 +140,8 @@ public:
virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const;
+ virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&,
+ const IceInternal::EndpointFactoryPtr&) const;
private:
diff --git a/cpp/src/IceBT/PluginI.cpp b/cpp/src/IceBT/PluginI.cpp
index 07a6fb67c42..c8f2882bbfb 100644
--- a/cpp/src/IceBT/PluginI.cpp
+++ b/cpp/src/IceBT/PluginI.cpp
@@ -59,13 +59,21 @@ registerIceBT(bool loadOnInitialize)
IceBT::PluginI::PluginI(const Ice::CommunicatorPtr& com) :
_engine(new Engine(com))
{
+ IceInternal::ProtocolPluginFacadePtr pluginFacade = IceInternal::getProtocolPluginFacade(com);
+
//
// Register the endpoint factory. We have to do this now, rather
// than in initialize, because the communicator may need to
// interpret proxies before the plug-in is fully initialized.
//
- IceInternal::EndpointFactoryPtr btFactory = new EndpointFactoryI(new Instance(_engine, EndpointType, "bt"));
- IceInternal::getProtocolPluginFacade(com)->addEndpointFactory(btFactory);
+ pluginFacade->addEndpointFactory(new EndpointFactoryI(new Instance(_engine, BTEndpointType, "bt")));
+
+ IceInternal::EndpointFactoryPtr sslFactory = pluginFacade->getEndpointFactory(SSLEndpointType);
+ if(sslFactory)
+ {
+ InstancePtr instance = new Instance(_engine, BTSEndpointType, "bts");
+ pluginFacade->addEndpointFactory(sslFactory->clone(instance, new EndpointFactoryI(instance)));
+ }
}
void
diff --git a/cpp/src/IceBT/StreamSocket.cpp b/cpp/src/IceBT/StreamSocket.cpp
index 7c398fbed6f..ba4b27ca57f 100644
--- a/cpp/src/IceBT/StreamSocket.cpp
+++ b/cpp/src/IceBT/StreamSocket.cpp
@@ -104,12 +104,12 @@ IceBT::StreamSocket::setBufferSize(int rcvSize, int sndSize)
// Warn if the size that was set is less than the requested size and
// we have not already warned.
//
- IceInternal::BufSizeWarnInfo winfo = _instance->getBufSizeWarn(EndpointType);
+ IceInternal::BufSizeWarnInfo winfo = _instance->getBufSizeWarn(BTEndpointType);
if(!winfo.rcvWarn || rcvSize != winfo.rcvSize)
{
Ice::Warning out(_instance->logger());
out << "BT receive buffer size: requested size of " << rcvSize << " adjusted to " << size;
- _instance->setRcvBufSizeWarn(EndpointType, rcvSize);
+ _instance->setRcvBufSizeWarn(BTEndpointType, rcvSize);
}
}
}
@@ -127,12 +127,12 @@ IceBT::StreamSocket::setBufferSize(int rcvSize, int sndSize)
{
// Warn if the size that was set is less than the requested size and
// we have not already warned.
- IceInternal::BufSizeWarnInfo winfo = _instance->getBufSizeWarn(EndpointType);
+ IceInternal::BufSizeWarnInfo winfo = _instance->getBufSizeWarn(BTEndpointType);
if(!winfo.sndWarn || sndSize != winfo.sndSize)
{
Ice::Warning out(_instance->logger());
out << "BT send buffer size: requested size of " << sndSize << " adjusted to " << size;
- _instance->setSndBufSizeWarn(EndpointType, sndSize);
+ _instance->setSndBufSizeWarn(BTEndpointType, sndSize);
}
}
}
diff --git a/cpp/src/IceBT/TransceiverI.cpp b/cpp/src/IceBT/TransceiverI.cpp
index fc4c878f35a..4a3f4005803 100644
--- a/cpp/src/IceBT/TransceiverI.cpp
+++ b/cpp/src/IceBT/TransceiverI.cpp
@@ -90,6 +90,11 @@ IceBT::TransceiverI::getInfo() const
IceBT::ConnectionInfoPtr info = ICE_MAKE_SHARED(IceBT::ConnectionInfo);
fdToAddressAndChannel(_stream->fd(), info->localAddress, info->localChannel, info->remoteAddress,
info->remoteChannel);
+ if(_stream->fd() != INVALID_SOCKET)
+ {
+ info->rcvSize = IceInternal::getRecvBufferSize(_stream->fd());
+ info->sndSize = IceInternal::getSendBufferSize(_stream->fd());
+ }
info->uuid = _uuid;
return info;
}
diff --git a/cpp/src/IceDiscovery/PluginI.cpp b/cpp/src/IceDiscovery/PluginI.cpp
index 5360dc14d31..615e0eeec96 100644
--- a/cpp/src/IceDiscovery/PluginI.cpp
+++ b/cpp/src/IceDiscovery/PluginI.cpp
@@ -28,17 +28,12 @@ using namespace IceDiscovery;
//
// Plugin factory function.
//
-extern "C"
-{
-
-ICE_DISCOVERY_API Ice::Plugin*
+extern "C" ICE_DISCOVERY_API Ice::Plugin*
createIceDiscovery(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&)
{
return new PluginI(communicator);
}
-}
-
namespace Ice
{
@@ -50,6 +45,15 @@ registerIceDiscovery(bool loadOnInitialize)
}
+//
+// Objective-C function to allow Objective-C programs to register plugin.
+//
+extern "C" ICE_DISCOVERY_API void
+ICEregisterIceDiscovery(bool loadOnInitialize)
+{
+ Ice::registerIceDiscovery(loadOnInitialize);
+}
+
PluginI::PluginI(const Ice::CommunicatorPtr& communicator) : _communicator(communicator)
{
}
diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp
index fb31d8d588b..d246b26dd9c 100644
--- a/cpp/src/IceGrid/RegistryI.cpp
+++ b/cpp/src/IceGrid/RegistryI.cpp
@@ -118,6 +118,19 @@ private:
ProcessPtr _origProcess;
};
+Ice::IPConnectionInfoPtr
+getIPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPConnectionInfoPtr ipInfo = Ice::IPConnectionInfoPtr::dynamicCast(p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
ProcessI::ProcessI(const RegistryIPtr& registry, const ProcessPtr& origProcess) :
_registry(registry),
@@ -1338,10 +1351,11 @@ RegistryI::getSSLInfo(const ConnectionPtr& connection, string& userDN)
throw exc;
}
- sslinfo.remotePort = info->remotePort;
- sslinfo.remoteHost = info->remoteAddress;
- sslinfo.localPort = info->localPort;
- sslinfo.localHost = info->localAddress;
+ Ice::IPConnectionInfoPtr ipInfo = getIPConnectionInfo(info);
+ sslinfo.remotePort = ipInfo->remotePort;
+ sslinfo.remoteHost = ipInfo->remoteAddress;
+ sslinfo.localPort = ipInfo->localPort;
+ sslinfo.localHost = ipInfo->localAddress;
sslinfo.cipher = info->cipher;
sslinfo.certs = info->certs;
if(info->certs.size() > 0)
diff --git a/cpp/src/Ice/ios/iAPConnector.h b/cpp/src/IceIAP/Connector.h
index f2bd4281d95..f2bd4281d95 100644
--- a/cpp/src/Ice/ios/iAPConnector.h
+++ b/cpp/src/IceIAP/Connector.h
diff --git a/cpp/src/Ice/ios/iAPConnector.mm b/cpp/src/IceIAP/Connector.mm
index 935858b9c6f..b7c57ddb31b 100644
--- a/cpp/src/Ice/ios/iAPConnector.mm
+++ b/cpp/src/IceIAP/Connector.mm
@@ -7,9 +7,9 @@
//
// **********************************************************************
-#include "iAPTransceiver.h"
-#include "iAPEndpointI.h"
-#include "iAPConnector.h"
+#include "Transceiver.h"
+#include "EndpointI.h"
+#include "Connector.h"
#include <Ice/ProtocolInstance.h>
#include <Ice/Exception.h>
diff --git a/cpp/src/Ice/ios/iAPEndpointI.h b/cpp/src/IceIAP/EndpointI.h
index dc85e085bf7..c4016073453 100644
--- a/cpp/src/Ice/ios/iAPEndpointI.h
+++ b/cpp/src/IceIAP/EndpointI.h
@@ -33,7 +33,7 @@ public:
iAPEndpointI(const IceInternal::ProtocolInstancePtr&);
iAPEndpointI(const IceInternal::ProtocolInstancePtr&, Ice::InputStream*);
- virtual void streamWrite(Ice::OutputStream*) const;
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual Ice::EndpointInfoPtr getInfo() const;
virtual Ice::Short type() const;
@@ -97,7 +97,8 @@ public:
virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const;
+ virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&,
+ const IceInternal::EndpointFactoryPtr&) const;
private:
diff --git a/cpp/src/Ice/ios/iAPEndpointI.mm b/cpp/src/IceIAP/EndpointI.mm
index 86ca8060fbc..44a0526d9ab 100644
--- a/cpp/src/Ice/ios/iAPEndpointI.mm
+++ b/cpp/src/IceIAP/EndpointI.mm
@@ -7,8 +7,10 @@
//
// **********************************************************************
-#include "iAPEndpointI.h"
-#include "iAPConnector.h"
+#include "EndpointI.h"
+#include "Connector.h"
+
+#include <IceIAP/EndpointInfo.h>
#include <Ice/Network.h>
#include <Ice/InputStream.h>
@@ -20,6 +22,8 @@
#include <Ice/EndpointFactoryManager.h>
#include <Ice/Properties.h>
#include <Ice/HashUtil.h>
+#include <Ice/ProtocolPluginFacade.h>
+#include <Ice/RegisterPlugins.h>
#include <CoreFoundation/CoreFoundation.h>
@@ -29,18 +33,62 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
-extern "C"
+namespace
+{
+
+class iAPEndpointFactoryPlugin : public Ice::Plugin
{
+public:
+
+ iAPEndpointFactoryPlugin(const Ice::CommunicatorPtr& com)
+ {
+ ProtocolPluginFacadePtr pluginFacade = getProtocolPluginFacade(com);
+
+ // iAP transport
+ ProtocolInstancePtr instance = new ProtocolInstance(com, iAPEndpointType, "iap", false);
+ pluginFacade->addEndpointFactory(new IceObjC::iAPEndpointFactory(instance));
+
+ // SSL based on iAP transport
+ EndpointFactoryPtr ssl = pluginFacade->getEndpointFactory(SSLEndpointType);
+ if(ssl)
+ {
+ ProtocolInstancePtr sslinstance = new ProtocolInstance(com, iAPSEndpointType, "iaps", true);
+ pluginFacade->addEndpointFactory(ssl->clone(sslinstance, new IceObjC::iAPEndpointFactory(sslinstance)));
+ }
+ }
-Plugin*
+ virtual void initialize() {}
+ virtual void destroy() {}
+};
+
+}
+
+extern "C" ICE_IAP_API Plugin*
createIceIAP(const CommunicatorPtr& com, const string&, const StringSeq&)
{
- ProtocolInstancePtr instance = new ProtocolInstance(com, iAPEndpointType, "iap", false);
- return new EndpointFactoryPlugin(com, new IceObjC::iAPEndpointFactory(instance));
+ return new iAPEndpointFactoryPlugin(com);
+}
+
+namespace Ice
+{
+
+ICE_IAP_API void
+registerIceIAP(bool loadOnInitialize)
+{
+ Ice::registerPluginFactory("IceIAP", createIceIAP, loadOnInitialize);
}
}
+//
+// Objective-C function to allow Objective-C programs to register plugin.
+//
+extern "C" ICE_IAP_API void
+ICEregisterIceIAP(bool loadOnInitialize)
+{
+ Ice::registerIceIAP(loadOnInitialize);
+}
+
IceObjC::iAPEndpointI::iAPEndpointI(const ProtocolInstancePtr& instance, const string& m,
const string& o, const string& n, const string& p, Int ti,
const string& conId, bool co) :
@@ -70,26 +118,33 @@ IceObjC::iAPEndpointI::iAPEndpointI(const ProtocolInstancePtr& instance, InputSt
s->read(const_cast<string&>(_manufacturer), false);
s->read(const_cast<string&>(_modelNumber), false);
s->read(const_cast<string&>(_name), false);
+ s->read(const_cast<string&>(_protocol), false);
s->read(const_cast<Int&>(_timeout));
s->read(const_cast<bool&>(_compress));
}
void
-IceObjC::iAPEndpointI::streamWrite(OutputStream* s) const
+IceObjC::iAPEndpointI::streamWriteImpl(OutputStream* s) const
{
- s->startEncapsulation();
s->write(_manufacturer, false);
s->write(_modelNumber, false);
s->write(_name, false);
+ s->write(_protocol, false);
s->write(_timeout);
s->write(_compress);
- s->endEncapsulation();
}
EndpointInfoPtr
IceObjC::iAPEndpointI::getInfo() const
{
- return 0;
+ IceIAP::EndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<IceIAP::EndpointInfo>, shared_from_this());
+ info->timeout = _timeout;
+ info->compress = _compress;
+ info->manufacturer = _manufacturer;
+ info->modelNumber = _modelNumber;
+ info->name = _name;
+ info->protocol = _protocol;
+ return info;
}
Short
@@ -131,7 +186,8 @@ IceObjC::iAPEndpointI::timeout(Int t) const
}
else
{
- return ICE_MAKE_SHARED(iAPEndpointI, _instance, _manufacturer, _modelNumber, _name, _protocol, t, _connectionId, _compress);
+ return ICE_MAKE_SHARED(iAPEndpointI, _instance, _manufacturer, _modelNumber, _name, _protocol, t, _connectionId,
+ _compress);
}
}
@@ -150,7 +206,8 @@ IceObjC::iAPEndpointI::connectionId(const string& cId) const
}
else
{
- return ICE_MAKE_SHARED(iAPEndpointI, _instance, _manufacturer, _modelNumber, _name, _protocol, _timeout, cId, _compress);
+ return ICE_MAKE_SHARED(iAPEndpointI, _instance, _manufacturer, _modelNumber, _name, _protocol, _timeout, cId,
+ _compress);
}
}
@@ -169,7 +226,8 @@ IceObjC::iAPEndpointI::compress(bool c) const
}
else
{
- return ICE_MAKE_SHARED(iAPEndpointI, _instance, _manufacturer, _modelNumber, _name, _protocol, _timeout, _connectionId, c);
+ return ICE_MAKE_SHARED(iAPEndpointI, _instance, _manufacturer, _modelNumber, _name, _protocol, _timeout,
+ _connectionId, c);
}
}
@@ -197,37 +255,28 @@ IceObjC::iAPEndpointI::connectors_async(Ice::EndpointSelectionType selType,
NSArray* array = [manager connectedAccessories];
NSEnumerator* enumerator = [array objectEnumerator];
EAAccessory* accessory = nil;
- int lastError = 0;
while((accessory = [enumerator nextObject]))
{
if(!accessory.connected)
{
- lastError = 1;
continue;
}
-
if(!_manufacturer.empty() && _manufacturer != [accessory.manufacturer UTF8String])
{
- lastError = 2;
continue;
}
if(!_modelNumber.empty() && _modelNumber != [accessory.modelNumber UTF8String])
{
- lastError = 3;
continue;
}
if(!_name.empty() && _name != [accessory.name UTF8String])
{
- lastError = 4;
continue;
}
-
if(![accessory.protocolStrings containsObject:protocol])
{
- lastError = 5;
continue;
}
-
c.push_back(new iAPConnector(_instance, _timeout, _connectionId, protocol, accessory));
}
[protocol release];
@@ -268,7 +317,8 @@ IceObjC::iAPEndpointI::equivalent(const EndpointIPtr& endpoint) const
}
return endpointI->_manufacturer == _manufacturer &&
endpointI->_modelNumber == _modelNumber &&
- endpointI->_name == _name;
+ endpointI->_name == _name &&
+ endpointI->_protocol == _protocol;
}
bool
@@ -304,6 +354,11 @@ IceObjC::iAPEndpointI::operator==(const Ice::LocalObject& r) const
return false;
}
+ if(_protocol != p->_protocol)
+ {
+ return false;
+ }
+
if(_timeout != p->_timeout)
{
return false;
@@ -372,6 +427,15 @@ IceObjC::iAPEndpointI::operator<(const Ice::LocalObject& r) const
return false;
}
+ if(_protocol < p->_protocol)
+ {
+ return true;
+ }
+ else if(p->_protocol < _protocol)
+ {
+ return false;
+ }
+
if(_timeout < p->_timeout)
{
return true;
@@ -477,6 +541,7 @@ IceObjC::iAPEndpointI::options() const
{
s << " -t " << _timeout;
}
+
if(_compress)
{
s << " -z";
@@ -491,6 +556,7 @@ IceObjC::iAPEndpointI::hash() const
hashAdd(h, _manufacturer);
hashAdd(h, _modelNumber);
hashAdd(h, _name);
+ hashAdd(h, _protocol);
hashAdd(h, _timeout);
hashAdd(h, _connectionId);
return h;
@@ -634,7 +700,7 @@ IceObjC::iAPEndpointFactory::destroy()
}
EndpointFactoryPtr
-IceObjC::iAPEndpointFactory::clone(const ProtocolInstancePtr& instance) const
+IceObjC::iAPEndpointFactory::clone(const ProtocolInstancePtr& instance, const IceInternal::EndpointFactoryPtr&) const
{
return new iAPEndpointFactory(instance);
}
diff --git a/cpp/src/IceIAP/Makefile.mk b/cpp/src/IceIAP/Makefile.mk
new file mode 100644
index 00000000000..daeffbead19
--- /dev/null
+++ b/cpp/src/IceIAP/Makefile.mk
@@ -0,0 +1,20 @@
+# **********************************************************************
+#
+# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+$(project)_libraries = IceIAP
+
+IceIAP_configs := xcodesdk cpp11-xcodesdk
+IceIAP_platforms := iphoneos iphonesimulator
+
+IceIAP_targetdir := $(libdir)
+IceIAP_dependencies := Ice
+IceIAP_sliceflags := --include-dir IceIAP --dll-export ICE_IAP_API
+IceIAP_cppflags := -DICE_IAP_API_EXPORTS
+
+projects += $(project)
diff --git a/cpp/src/Ice/ios/iAPTransceiver.h b/cpp/src/IceIAP/Transceiver.h
index 6aaeb731241..b82ed27c395 100644
--- a/cpp/src/Ice/ios/iAPTransceiver.h
+++ b/cpp/src/IceIAP/Transceiver.h
@@ -66,6 +66,7 @@ private:
void checkError(NSError*, const char*, int);
IceInternal::ProtocolInstancePtr _instance;
+ EASession* _session;
NSInputStream* _readStream;
NSOutputStream* _writeStream;
iAPTransceiverCallback* _callback;
diff --git a/cpp/src/Ice/ios/iAPTransceiver.mm b/cpp/src/IceIAP/Transceiver.mm
index 3139b8f608e..a9a57dbf407 100644
--- a/cpp/src/Ice/ios/iAPTransceiver.mm
+++ b/cpp/src/IceIAP/Transceiver.mm
@@ -7,8 +7,10 @@
//
// **********************************************************************
-#include "iAPTransceiver.h"
-#include "iAPEndpointI.h"
+#include "Transceiver.h"
+#include "EndpointI.h"
+
+#include <IceIAP/ConnectionInfo.h>
#include <Ice/LocalException.h>
#include <Ice/ProtocolInstance.h>
@@ -62,8 +64,7 @@ using namespace IceInternal;
callback->readyCallback(static_cast<SocketOperation>(SocketOperationConnect | SocketOperationWrite));
}
break;
- case NSStreamEventEndEncountered:
- case NSStreamEventErrorOccurred:
+ default:
if([[stream class] isSubclassOfClass:[NSInputStream class]])
{
callback->readyCallback(SocketOperationRead, -1); // Error
@@ -88,7 +89,6 @@ SocketOperation
IceObjC::iAPTransceiver::registerWithRunLoop(SocketOperation op)
{
IceUtil::Mutex::Lock sync(_mutex);
-
SocketOperation readyOp = SocketOperationNone;
if(op & SocketOperationConnect)
{
@@ -236,39 +236,16 @@ IceObjC::iAPTransceiver::initialize(Buffer& readBuffer, Buffer& writeBuffer)
{
if(_error)
{
- assert([_writeStream streamStatus] == NSStreamStatusError);
- NSError* err = [_writeStream streamError];
- NSString* domain = [err domain];
- if([domain compare:NSPOSIXErrorDomain] == NSOrderedSame)
+ NSError* err = nil;
+ if([_writeStream streamStatus] == NSStreamStatusError)
{
- errno = [err code];
- [err release];
- if(connectionRefused())
- {
- ConnectionRefusedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else if(connectFailed())
- {
- ConnectFailedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ err = [_writeStream streamError];
}
-
- // Otherwise throw a generic exception.
- CFNetworkException ex(__FILE__, __LINE__);
- ex.domain = [domain UTF8String];
- ex.error = [err code];
- [err release];
- throw ex;
+ if([_readStream streamStatus] == NSStreamStatusError)
+ {
+ err = [_readStream streamError];
+ }
+ checkError(err, __FILE__, __LINE__);
}
_state = StateConnected;
}
@@ -296,7 +273,7 @@ IceObjC::iAPTransceiver::close()
SocketOperation
IceObjC::iAPTransceiver::write(Buffer& buf)
{
- IceUtil::Mutex::Lock sync(_mutex);
+ IceUtil::Mutex::Lock sync(_mutex);
if(_error)
{
assert([_writeStream streamStatus] == NSStreamStatusError);
@@ -421,7 +398,14 @@ IceObjC::iAPTransceiver::toDetailedString() const
Ice::ConnectionInfoPtr
IceObjC::iAPTransceiver::getInfo() const
{
- return 0;
+ IceIAP::ConnectionInfoPtr info = new IceIAP::ConnectionInfo();
+ info->manufacturer = [_session.accessory.manufacturer UTF8String];
+ info->name = [_session.accessory.name UTF8String];
+ info->modelNumber = [_session.accessory.modelNumber UTF8String];
+ info->firmwareRevision = [_session.accessory.firmwareRevision UTF8String];
+ info->hardwareRevision = [_session.accessory.hardwareRevision UTF8String];
+ info->protocol = [_session.protocolString UTF8String];
+ return info;
}
void
@@ -437,20 +421,23 @@ IceObjC::iAPTransceiver::setBufferSize(int, int)
IceObjC::iAPTransceiver::iAPTransceiver(const ProtocolInstancePtr& instance, EASession* session) :
StreamNativeInfo(INVALID_SOCKET),
_instance(instance),
- _readStream([[session inputStream] retain]),
- _writeStream([[session outputStream] retain]),
+ _session([session retain]),
+ _readStream([session inputStream]),
+ _writeStream([session outputStream]),
_readStreamRegistered(false),
_writeStreamRegistered(false),
_error(false),
_state(StateNeedConnect)
{
- _desc = string("name = ") + [session.accessory.name UTF8String];
+ ostringstream os;
+ os << "name = " << [session.accessory.name UTF8String] << "\n";
+ os << "protocol = " << [session.protocolString UTF8String];
+ _desc = os.str();
}
IceObjC::iAPTransceiver::~iAPTransceiver()
{
- [_readStream release];
- [_writeStream release];
+ [_session release];
}
void
diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp
index 4851e98bfcc..ee1e79d9c99 100644
--- a/cpp/src/IceLocatorDiscovery/PluginI.cpp
+++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp
@@ -27,17 +27,12 @@ using namespace IceLocatorDiscovery;
//
// Plugin factory function.
//
-extern "C"
-{
-
-ICE_LOCATOR_DISCOVERY_API Ice::Plugin*
+extern "C" ICE_LOCATOR_DISCOVERY_API Ice::Plugin*
createIceLocatorDiscovery(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&)
{
return new PluginI(communicator);
}
-}
-
namespace Ice
{
@@ -49,6 +44,15 @@ registerIceLocatorDiscovery(bool loadOnInitialize)
}
+//
+// Objective-C function to allow Objective-C programs to register plugin.
+//
+extern "C" ICE_LOCATOR_DISCOVERY_API void
+ICEregisterIceLocatorDiscovery(bool loadOnInitialize)
+{
+ Ice::registerIceLocatorDiscovery(loadOnInitialize);
+}
+
namespace
{
diff --git a/cpp/src/IcePatch2/Server.cpp b/cpp/src/IcePatch2/Server.cpp
index f0d0dc21b32..b559a091796 100644
--- a/cpp/src/IcePatch2/Server.cpp
+++ b/cpp/src/IcePatch2/Server.cpp
@@ -53,7 +53,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[], int& status)
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
-
+
vector<string> args;
try
{
@@ -109,7 +109,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[], int& status)
{
throw "cannot get the current directory:\n" + IceUtilInternal::lastErrorToString();
}
-
+
dataDir = cwd + '/' + dataDir;
}
@@ -125,7 +125,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[], int& status)
error(ex);
return false;
}
-
+
const string endpointsProperty = "IcePatch2.Endpoints";
string endpoints = properties->getProperty(endpointsProperty);
if(endpoints.empty())
diff --git a/cpp/src/IceSSL/AcceptorI.cpp b/cpp/src/IceSSL/AcceptorI.cpp
index 7f8c70341ed..8042fb8d195 100644
--- a/cpp/src/IceSSL/AcceptorI.cpp
+++ b/cpp/src/IceSSL/AcceptorI.cpp
@@ -11,23 +11,15 @@
#include <IceSSL/EndpointI.h>
#include <IceSSL/Instance.h>
+
#include <IceSSL/OpenSSLTransceiverI.h>
#include <IceSSL/SecureTransportTransceiverI.h>
#include <IceSSL/SChannelTransceiverI.h>
+#include <IceSSL/WinRTTransceiverI.h>
#include <IceSSL/Util.h>
-#include <Ice/Communicator.h>
-#include <Ice/Exception.h>
#include <Ice/LocalException.h>
-#include <Ice/LoggerUtil.h>
-#include <Ice/Properties.h>
-#include <Ice/StreamSocket.h>
-#include <IceUtil/StringUtil.h>
-
-#ifdef ICE_USE_IOCP
-# include <Mswsock.h>
-#endif
using namespace std;
using namespace Ice;
@@ -38,90 +30,43 @@ IceUtil::Shared* IceSSL::upCast(AcceptorI* p) { return p; }
IceInternal::NativeInfoPtr
IceSSL::AcceptorI::getNativeInfo()
{
- return this;
+ return _delegate->getNativeInfo();
}
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
IceInternal::AsyncInfo*
-IceSSL::AcceptorI::getAsyncInfo(IceInternal::SocketOperation)
+IceSSL::AcceptorI::getAsyncInfo(IceInternal::SocketOperation status)
{
- return &_info;
+ return _delegate->getNativeInfo()->getAsyncInfo(status);
}
#endif
void
IceSSL::AcceptorI::close()
{
- if(_fd != INVALID_SOCKET)
- {
- IceInternal::closeSocketNoThrow(_fd);
- _fd = INVALID_SOCKET;
- }
+ _delegate->close();
}
IceInternal::EndpointIPtr
IceSSL::AcceptorI::listen()
{
- try
- {
- const_cast<IceInternal::Address&>(_addr) = IceInternal::doBind(_fd, _addr);
- IceInternal::doListen(_fd, _backlog);
- }
- catch(...)
- {
- _fd = INVALID_SOCKET;
- throw;
- }
- _endpoint = _endpoint->endpoint(this);
+ _endpoint = _endpoint->endpoint(_delegate->listen());
return _endpoint;
}
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
void
IceSSL::AcceptorI::startAccept()
{
- LPFN_ACCEPTEX AcceptEx = NULL; // a pointer to the 'AcceptEx()' function
- GUID GuidAcceptEx = WSAID_ACCEPTEX; // The Guid
- DWORD dwBytes;
- if(WSAIoctl(_fd,
- SIO_GET_EXTENSION_FUNCTION_POINTER,
- &GuidAcceptEx,
- sizeof(GuidAcceptEx),
- &AcceptEx,
- sizeof(AcceptEx),
- &dwBytes,
- NULL,
- NULL) == SOCKET_ERROR)
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
- }
+ _delegate->startAccept();
- assert(_acceptFd == INVALID_SOCKET);
- _acceptFd = IceInternal::createSocket(false, _addr);
- const int sz = static_cast<int>(_acceptBuf.size() / 2);
- if(!AcceptEx(_fd, _acceptFd, &_acceptBuf[0], 0, sz, sz, &_info.count, &_info))
- {
- if(!IceInternal::wouldBlock())
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
- }
- }
}
void
IceSSL::AcceptorI::finishAccept()
{
- if(static_cast<int>(_info.count) == SOCKET_ERROR || _fd == INVALID_SOCKET)
- {
- IceInternal::closeSocketNoThrow(_acceptFd);
- _acceptFd = INVALID_SOCKET;
- _acceptError = _info.error;
- }
+ _delegate->finishAccept();
}
#endif
@@ -138,121 +83,36 @@ IceSSL::AcceptorI::accept()
throw ex;
}
-#ifndef ICE_USE_IOCP
- SOCKET fd = IceInternal::doAccept(_fd);
-#else
- if(_acceptFd == INVALID_SOCKET)
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = _acceptError;
- throw ex;
- }
-
- if(setsockopt(_acceptFd, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, (char*)&_acceptFd, sizeof(_acceptFd)) ==
- SOCKET_ERROR)
- {
- IceInternal::closeSocketNoThrow(_acceptFd);
- _acceptFd = INVALID_SOCKET;
- SocketException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
- }
-
- SOCKET fd = _acceptFd;
- _acceptFd = INVALID_SOCKET;
-#endif
-
- //
- // SSL handshaking is performed in TransceiverI::initialize, since
- // accept must not block.
- //
- return new TransceiverI(_instance, new IceInternal::StreamSocket(_instance, fd), _adapterName, true);
+ return new TransceiverI(_instance, _delegate->accept(), _adapterName, true);
}
string
IceSSL::AcceptorI::protocol() const
{
- return _instance->protocol();
+ return _delegate->protocol();
}
string
IceSSL::AcceptorI::toString() const
{
- return IceInternal::addrToString(_addr);
+ return _delegate->toString();
}
string
IceSSL::AcceptorI::toDetailedString() const
{
- ostringstream os;
- os << "local address = " << toString();
- vector<string> intfs = getHostsForEndpointExpand(inetAddrToString(_addr), _instance->protocolSupport(), true);
- if(!intfs.empty())
- {
- os << "\nlocal interfaces = ";
- os << IceUtilInternal::joinString(intfs, ", ");
- }
- return os.str();
+ return _delegate->toDetailedString();
}
-int
-IceSSL::AcceptorI::effectivePort() const
-{
- if(_addr.saStorage.ss_family == AF_INET)
- {
- return ntohs(_addr.saIn.sin_port);
- }
- else
- {
- return ntohs(_addr.saIn6.sin6_port);
- }
-}
-
-IceSSL::AcceptorI::AcceptorI(const EndpointIPtr& endpoint, const InstancePtr& instance, const string& adapterName,
- const string& host, int port) :
+IceSSL::AcceptorI::AcceptorI(const EndpointIPtr& endpoint, const InstancePtr& instance,
+ const IceInternal::AcceptorPtr& del, const string& adapterName) :
_endpoint(endpoint),
_instance(instance),
- _adapterName(adapterName),
- _addr(IceInternal::getAddressForServer(host, port, instance->protocolSupport(), instance->preferIPv6()))
-#ifdef ICE_USE_IOCP
- , _acceptFd(INVALID_SOCKET),
- _info(IceInternal::SocketOperationRead)
-#endif
+ _delegate(del),
+ _adapterName(adapterName)
{
-#ifdef SOMAXCONN
- _backlog = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.Backlog", SOMAXCONN);
-#else
- _backlog = instance->properties()->getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);
-#endif
-
- IceInternal::ProtocolSupport protocol = instance->protocolSupport();
- _fd = IceInternal::createServerSocket(false, _addr, protocol);
-#ifdef ICE_USE_IOCP
- _acceptBuf.resize((sizeof(sockaddr_storage) + 16) * 2);
-#endif
- IceInternal::setBlock(_fd, false);
- IceInternal::setTcpBufSize(_fd, _instance);
-#ifndef _WIN32
- //
- // Enable SO_REUSEADDR on Unix platforms to allow re-using the
- // socket even if it's in the TIME_WAIT state. On Windows,
- // this doesn't appear to be necessary and enabling
- // SO_REUSEADDR would actually not be a good thing since it
- // allows a second process to bind to an address even it's
- // already bound by another process.
- //
- // TODO: using SO_EXCLUSIVEADDRUSE on Windows would probably
- // be better but it's only supported by recent Windows
- // versions (XP SP2, Windows Server 2003).
- //
- IceInternal::setReuseAddress(_fd, true);
-#endif
}
IceSSL::AcceptorI::~AcceptorI()
{
- assert(_fd == INVALID_SOCKET);
-#ifdef ICE_USE_IOCP
- assert(_acceptFd == INVALID_SOCKET);
-#endif
}
diff --git a/cpp/src/IceSSL/AcceptorI.h b/cpp/src/IceSSL/AcceptorI.h
index 465878a24c2..3ee5d5d2d4c 100644
--- a/cpp/src/IceSSL/AcceptorI.h
+++ b/cpp/src/IceSSL/AcceptorI.h
@@ -25,13 +25,13 @@ class AcceptorI : public IceInternal::Acceptor, public IceInternal::NativeInfo
public:
virtual IceInternal::NativeInfoPtr getNativeInfo();
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual IceInternal::AsyncInfo* getAsyncInfo(IceInternal::SocketOperation);
#endif
virtual void close();
virtual IceInternal::EndpointIPtr listen();
-#ifdef ICE_USE_IOCP
+#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
virtual void startAccept();
virtual void finishAccept();
#endif
@@ -40,25 +40,16 @@ public:
virtual std::string toString() const;
virtual std::string toDetailedString() const;
- int effectivePort() const;
-
private:
- AcceptorI(const EndpointIPtr&, const InstancePtr&, const std::string&, const std::string&, int);
+ AcceptorI(const EndpointIPtr&, const InstancePtr&, const IceInternal::AcceptorPtr&, const std::string&);
virtual ~AcceptorI();
friend class EndpointI;
EndpointIPtr _endpoint;
const InstancePtr _instance;
+ const IceInternal::AcceptorPtr _delegate;
const std::string _adapterName;
- const IceInternal::Address _addr;
- int _backlog;
-#ifdef ICE_USE_IOCP
- SOCKET _acceptFd;
- int _acceptError;
- std::vector<char> _acceptBuf;
- IceInternal::AsyncInfo _info;
-#endif
};
}
diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp
index 61597bdd0fe..5429a96b2e9 100644..100755
--- a/cpp/src/IceSSL/Certificate.cpp
+++ b/cpp/src/IceSSL/Certificate.cpp
@@ -15,6 +15,7 @@
#include <IceSSL/Util.h>
#include <IceSSL/RFC2253.h>
#include <Ice/Object.h>
+#include <Ice/Base64.h>
#if defined(ICE_USE_OPENSSL)
# include <openssl/x509v3.h>
@@ -42,12 +43,12 @@ extern "C" typedef void (*FreeFunc)(void*);
#endif
-
using namespace std;
using namespace Ice;
using namespace IceSSL;
#if defined(ICE_USE_SECURE_TRANSPORT) || defined(ICE_USE_SCHANNEL)
+
//
// Map a certificate OID to its alias
//
@@ -80,7 +81,6 @@ const int certificateOIDSSize = sizeof(certificateOIDS) / sizeof(CertificateOID)
#endif
-
#if defined(ICE_USE_SECURE_TRANSPORT)
string
@@ -98,29 +98,6 @@ certificateOIDAlias(const string& name)
return name;
}
-//
-// Map alternative name alias to its types.
-//
-const char* certificateAlternativeNameTypes[] = {"", "Email Address", "DNS Name", "", "Directory Name", "", "URI",
- "IP Address"};
-const int certificateAlternativeNameTypesSize = sizeof(certificateAlternativeNameTypes) / sizeof(char*);
-
-int
-certificateAlternativeNameType(const string& alias)
-{
- if(!alias.empty())
- {
- for(int i = 0; i < certificateAlternativeNameTypesSize; ++i)
- {
- if(alias == certificateAlternativeNameTypes[i])
- {
- return i;
- }
- }
- }
- return -1; // Not supported
-}
-
string
escapeX509Name(const string& name)
{
@@ -149,6 +126,31 @@ escapeX509Name(const string& name)
return os.str();
}
+#if !defined(ICE_USE_SECURE_TRANSPORT_IOS)
+
+//
+// Map alternative name alias to its types.
+//
+const char* certificateAlternativeNameTypes[] = {"", "Email Address", "DNS Name", "", "Directory Name", "", "URI",
+ "IP Address"};
+const int certificateAlternativeNameTypesSize = sizeof(certificateAlternativeNameTypes) / sizeof(char*);
+
+int
+certificateAlternativeNameType(const string& alias)
+{
+ if(!alias.empty())
+ {
+ for(int i = 0; i < certificateAlternativeNameTypesSize; ++i)
+ {
+ if(alias == certificateAlternativeNameTypes[i])
+ {
+ return i;
+ }
+ }
+ }
+ return -1; // Not supported
+}
+
DistinguishedName
getX509Name(SecCertificateRef cert, CFTypeRef key)
{
@@ -256,8 +258,158 @@ getX509String(SecCertificateRef cert, CFTypeRef key)
return value;
}
-#elif defined(ICE_USE_SCHANNEL)
+#else // IOS
+
+//
+// ASN1Parser to pase the subject/issuer ASN.1 DER encoded attributes on iOS.
+//
+class ASN1Parser
+{
+public:
+
+ ASN1Parser(CFDataRef data) : _data(CFDataGetBytePtr(data)), _length(CFDataGetLength(data)), _p(_data), _next(0)
+ {
+ }
+
+ list<pair<string, string> >
+ parse()
+ {
+ list<pair<string, string> > rdns;
+ while(_p < _data + _length)
+ {
+ switch(parseByte())
+ {
+ case 0x06: // OID
+ {
+ _rdn.first = parseOID();
+ break;
+ }
+ case 0x12: // NumericString
+ case 0x13: // PrintableString
+ case 0x0C: // UTF8String
+ case 0x16: // IA5String
+ {
+ _rdn.second = escapeX509Name(parseUTF8String());
+ break;
+ }
+ case 0x30: // SEQUENCE
+ case 0x31: // SET
+ {
+ int length = parseLength(0);
+ _next = _p + length;
+ if(_next > _data + _length)
+ {
+ throw CertificateEncodingException(__FILE__, __LINE__, "invalid length");
+ }
+ break;
+ }
+ default:
+ {
+ // Unsupported tag, skip the SET.
+ if(!_next)
+ {
+ return rdns;
+ }
+ _p = _next;
+ _next = 0;
+ break;
+ }
+ }
+ if(_p == _next)
+ {
+ rdns.push_back(_rdn);
+ }
+ }
+ return rdns;
+ }
+
+ string
+ parseOID()
+ {
+ int length = parseLength(1);
+ ostringstream oid;
+ unsigned char c = parseByte();
+ oid << c / 40 << "." << c % 40;
+ while(--length > 0)
+ {
+ if((*_p & 0x80) == 0)
+ {
+ oid << "." << static_cast<int>(parseByte());
+ }
+ else
+ {
+ uint64_t result = (uint64_t)(*_p & 127);
+ while(parseByte() & 128)
+ {
+ result = (result << 7) | (uint64_t)(*_p & 127);
+ --length;
+ }
+ oid << "." << result;
+ }
+ }
+ return certificateOIDAlias(oid.str());
+ }
+
+ string
+ parseUTF8String()
+ {
+ int length = parseLength(0);
+ string v(reinterpret_cast<const char*>(_p), length);
+ _p += length;
+ return v;
+ }
+ int
+ parseLength(int required)
+ {
+ int length = 0;
+ if((*_p & 0x80) == 0)
+ {
+ length = static_cast<int>(parseByte());
+ }
+ else
+ {
+ int nbytes = static_cast<int>(parseByte());
+ for(int i = 0; i < nbytes; ++i)
+ {
+ length = length * 256 + parseByte();
+ }
+ }
+ if((required > 0 && length < required) || (_p + length > _data + _length))
+ {
+ throw CertificateEncodingException(__FILE__, __LINE__, "invalid length");
+ }
+ return length;
+ }
+
+ unsigned char
+ parseByte()
+ {
+ if(_p >= _data + _length)
+ {
+ throw CertificateEncodingException(__FILE__, __LINE__, "invalid length");
+ }
+ unsigned char b = *_p++;
+ return b;
+ }
+
+private:
+
+ const unsigned char* _data;
+ const size_t _length;
+ const unsigned char* _p;
+ const unsigned char* _next;
+ pair<string, string> _rdn;
+ list<pair<string, string> > _rdns;
+};
+#endif
+
+#elif defined(ICE_USE_SCHANNEL) || defined(ICE_OS_WINRT)
+
+const Ice::Long TICKS_PER_MSECOND = 10000LL;
+const Ice::Long MSECS_TO_EPOCH = 11644473600000LL;
+
+#if defined(ICE_USE_SCHANNEL)
void
loadCertificate(PCERT_SIGNED_CONTENT_INFO* cert, const char* buffer, DWORD length)
{
@@ -294,9 +446,6 @@ loadCertificate(PCERT_SIGNED_CONTENT_INFO* cert, const string& file)
loadCertificate(cert, &buffer[0], static_cast<DWORD>(buffer.size()));
}
-const Ice::Long TICKS_PER_MSECOND = 10000LL;
-const Ice::Long MSECS_TO_EPOCH = 11644473600000LL;
-
IceUtil::Time
filetimeToTime(FILETIME ftime)
{
@@ -419,6 +568,32 @@ certificateAltNames(CERT_INFO* certInfo, LPCSTR altNameOID)
}
return altNames;
}
+#else
+
+vector<pair<int, string> >
+certificateAltNames(Windows::Security::Cryptography::Certificates::SubjectAlternativeNameInfo^ subAltNames)
+{
+ vector<pair<int, string> > altNames;
+ for (auto iter = subAltNames->EmailName->First(); iter->HasCurrent; iter->MoveNext())
+ {
+ altNames.push_back(make_pair(AltNameEmail, IceUtil::wstringToString(iter->Current->Data())));
+ }
+ for (auto iter = subAltNames->DnsName->First(); iter->HasCurrent; iter->MoveNext())
+ {
+ altNames.push_back(make_pair(AltNameDNS, IceUtil::wstringToString(iter->Current->Data())));
+ }
+ for (auto iter = subAltNames->Url->First(); iter->HasCurrent; iter->MoveNext())
+ {
+ altNames.push_back(make_pair(AltNameURL, IceUtil::wstringToString(iter->Current->Data())));
+ }
+ for (auto iter = subAltNames->IPAddress->First(); iter->HasCurrent; iter->MoveNext())
+ {
+ altNames.push_back(make_pair(AltNAmeIP, IceUtil::wstringToString(iter->Current->Data())));
+ }
+ return altNames;
+}
+#endif
+
#endif
CertificateReadException::CertificateReadException(const char* file, int line, const string& r) :
@@ -700,21 +875,25 @@ ParseException::ice_throw() const
}
#ifdef ICE_USE_OPENSSL
-DistinguishedName::DistinguishedName(X509NAME* name) :
- _rdns(RFC2253::parseStrict(convertX509NameToString(name)))
+DistinguishedName::DistinguishedName(X509NAME* name) : _rdns(RFC2253::parseStrict(convertX509NameToString(name)))
{
unescape();
}
#endif
-DistinguishedName::DistinguishedName(const string& dn) :
- _rdns(RFC2253::parseStrict(dn))
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+DistinguishedName::DistinguishedName(CFDataRef data) : _rdns(ASN1Parser(data).parse())
{
unescape();
}
+#endif
-DistinguishedName::DistinguishedName(const list<pair<string, string> >& rdns) :
- _rdns(rdns)
+DistinguishedName::DistinguishedName(const string& dn) : _rdns(RFC2253::parseStrict(dn))
+{
+ unescape();
+}
+
+DistinguishedName::DistinguishedName(const list<pair<string, string> >& rdns) : _rdns(rdns)
{
unescape();
}
@@ -810,7 +989,7 @@ PublicKey::~PublicKey()
{
# if defined(ICE_USE_SECURE_TRANSPORT)
CFRelease(_key);
-# else
+# elif defined(ICE_USE_OPENSSL)
EVP_PKEY_free(_key);
# endif
}
@@ -827,9 +1006,6 @@ PublicKey::key() const
// The caller is responsible for incrementing the reference count.
//
Certificate::Certificate(X509CertificateRef cert) : _cert(cert)
-#ifdef ICE_USE_SCHANNEL
- , _certInfo(0)
-#endif
{
if(!_cert)
{
@@ -837,6 +1013,7 @@ Certificate::Certificate(X509CertificateRef cert) : _cert(cert)
}
#ifdef ICE_USE_SCHANNEL
+ _certInfo = 0;
try
{
//
@@ -856,13 +1033,28 @@ Certificate::Certificate(X509CertificateRef cert) : _cert(cert)
throw;
}
#endif
+
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ _subject = NULL;
+ _issuer = NULL;
+#endif
}
Certificate::~Certificate()
{
if(_cert)
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ if(_subject)
+ {
+ CFRelease(_subject);
+ }
+ if(_issuer)
+ {
+ CFRelease(_issuer);
+ }
+ CFRelease(_cert);
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
CFRelease(_cert);
#elif defined(ICE_USE_SCHANNEL)
LocalFree(_cert);
@@ -870,7 +1062,7 @@ Certificate::~Certificate()
{
LocalFree(_certInfo);
}
-#else
+#elif defined(ICE_USE_OPENSSL)
X509_free(_cert);
#endif
}
@@ -880,12 +1072,20 @@ CertificatePtr
Certificate::load(const string& file)
{
#if defined(ICE_USE_SECURE_TRANSPORT)
- return ICE_MAKE_SHARED(Certificate, loadCertificate(file));
+ string resolved;
+ if(checkPath(file, "", false, resolved))
+ {
+ return ICE_MAKE_SHARED(Certificate, loadCertificate(resolved));
+ }
+ else
+ {
+ throw CertificateReadException(__FILE__, __LINE__, "error opening file " + file);
+ }
#elif defined(ICE_USE_SCHANNEL)
CERT_SIGNED_CONTENT_INFO* cert;
loadCertificate(&cert, file);
return ICE_MAKE_SHARED(Certificate, cert);
-#else
+#elif defined(ICE_USE_OPENSSL)
BIO *cert = BIO_new(BIO_s_file());
if(BIO_read_filename(cert, file.c_str()) <= 0)
{
@@ -901,16 +1101,45 @@ Certificate::load(const string& file)
}
BIO_free(cert);
return ICE_MAKE_SHARED(Certificate, x);
+#elif defined(ICE_OS_WINRT)
+ // TODO
+ return ICE_NULLPTR;
+#else
+# error "Unknown platform"
#endif
}
CertificatePtr
Certificate::decode(const string& encoding)
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ string::size_type size, startpos, endpos = 0;
+ startpos = encoding.find("-----BEGIN CERTIFICATE-----", endpos);
+ if(startpos != string::npos)
+ {
+ startpos += sizeof("-----BEGIN CERTIFICATE-----");
+ endpos = encoding.find("-----END CERTIFICATE-----", startpos);
+ size = endpos - startpos;
+ }
+ else
+ {
+ startpos = 0;
+ endpos = string::npos;
+ size = encoding.size();
+ }
+
+ vector<unsigned char> data(IceInternal::Base64::decode(string(&encoding[startpos], size)));
+ UniqueRef<CFDataRef> certdata(CFDataCreate(kCFAllocatorDefault, &data[0], data.size()));
+ SecCertificateRef cert = SecCertificateCreateWithData(0, certdata.get());
+ if(!cert)
+ {
+ assert(false);
+ throw CertificateEncodingException(__FILE__, __LINE__, "certificate is not a valid PEM-encoded certificate");
+ }
+ return ICE_MAKE_SHARED(Certificate, cert);
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(encoding.c_str()),
encoding.size(), kCFAllocatorNull);
-
SecExternalFormat format = kSecFormatUnknown;
SecExternalItemType type = kSecItemTypeCertificate;
@@ -929,14 +1158,13 @@ Certificate::decode(const string& encoding)
SecKeychainItemRef item = (SecKeychainItemRef)CFArrayGetValueAtIndex(items, 0);
CFRetain(item);
CFRelease(items);
-
assert(SecCertificateGetTypeID() == CFGetTypeID(item));
return ICE_MAKE_SHARED(Certificate, (SecCertificateRef)item);
#elif defined(ICE_USE_SCHANNEL)
CERT_SIGNED_CONTENT_INFO* cert;
loadCertificate(&cert, encoding.c_str(), static_cast<DWORD>(encoding.size()));
return ICE_MAKE_SHARED(Certificate, cert);
-#else
+#elif defined(ICE_USE_OPENSSL)
BIO *cert = BIO_new_mem_buf(static_cast<void*>(const_cast<char*>(&encoding[0])), static_cast<int>(encoding.size()));
X509CertificateRef x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
if(x == NULL)
@@ -946,6 +1174,11 @@ Certificate::decode(const string& encoding)
}
BIO_free(cert);
return ICE_MAKE_SHARED(Certificate, x);
+#elif defined(ICE_OS_WINRT)
+ // TODO
+ return ICE_NULLPTR;
+#else
+# error "Unknown platform"
#endif
}
@@ -956,27 +1189,27 @@ Certificate::operator==(const Certificate& other) const
return CFEqual(_cert, other._cert);
#elif defined(ICE_USE_SCHANNEL)
return CertCompareCertificate(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, _certInfo, other._certInfo);
-#else
+#elif defined(ICE_USE_OPENSSL)
return X509_cmp(_cert, other._cert) == 0;
+#elif defined(ICE_OS_WINRT)
+ return _cert->Equals(other._cert);
+#else
+# error "Unknown platform"
#endif
}
bool
Certificate::operator!=(const Certificate& other) const
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
- return !CFEqual(_cert, other._cert);
-#elif defined(ICE_USE_SCHANNEL)
- return !CertCompareCertificate(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, _certInfo, other._certInfo);
-#else
- return X509_cmp(_cert, other._cert) != 0;
-#endif
+ return !operator==(other);
}
PublicKeyPtr
Certificate::getPublicKey() const
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ return ICE_NULLPTR; // Not supported
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
SecKeyRef key;
OSStatus err = SecCertificateCopyPublicKey(_cert, &key);
if(err)
@@ -986,8 +1219,12 @@ Certificate::getPublicKey() const
return ICE_MAKE_SHARED(PublicKey, shared_from_this(), key);
#elif defined(ICE_USE_SCHANNEL)
return ICE_MAKE_SHARED(PublicKey, shared_from_this(), &_certInfo->SubjectPublicKeyInfo);
-#else
+#elif defined(ICE_USE_OPENSSL)
return ICE_MAKE_SHARED(PublicKey, shared_from_this(), X509_get_pubkey(_cert));
+#elif defined(ICE_OS_WINRT)
+ return ICE_NULLPTR; // Not supported
+#else
+# error "Unknown platform"
#endif
}
@@ -996,17 +1233,20 @@ Certificate::verify(const CertificatePtr& cert) const
{
#if defined(ICE_USE_SECURE_TRANSPORT)
//
- // We first check if the given certificate subject match
- // our certificate issuer. Otherwhise when use SecTrustEvaluate
- // and check a certificate against itself will always return
- // that is valid.
+ // We first check if the given certificate subject match our certificate
+ // issuer. Otherwhise when checking a certificate against itself
+ // SecTrustEvaluate always returns it is valid.
//
bool valid = false;
- CFErrorRef error = 0;
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ initializeAttributes();
+ cert->initializeAttributes();
+ valid = CFEqual(_issuer, cert->_subject);
+#else
CFDataRef issuer = 0;
CFDataRef subject = 0;
-
+ CFErrorRef error = 0;
try
{
issuer = SecCertificateCopyNormalizedIssuerContent(_cert, &error);
@@ -1042,7 +1282,7 @@ Certificate::verify(const CertificatePtr& cert) const
CFRelease(issuer);
CFRelease(subject);
-
+#endif
if(valid)
{
SecPolicyRef policy = 0;
@@ -1107,8 +1347,12 @@ Certificate::verify(const CertificatePtr& cert) const
bool result = CryptVerifyCertificateSignature(0, X509_ASN_ENCODING, buffer, length, cert->getPublicKey()->key());
LocalFree(buffer);
return result;
-#else
+#elif defined(ICE_USE_OPENSSL)
return X509_verify(_cert, cert->getPublicKey()->key()) > 0;
+#elif defined(ICE_OS_WINRT)
+ return false;
+#else
+# error "Unknown platform"
#endif
}
@@ -1123,7 +1367,15 @@ Certificate::verify(const PublicKeyPtr& key) const
string
Certificate::encode() const
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ UniqueRef<CFDataRef> c(SecCertificateCopyData(_cert));
+ vector<unsigned char> data(CFDataGetBytePtr(c.get()), CFDataGetBytePtr(c.get()) + CFDataGetLength(c.get()));
+ ostringstream os;
+ os << "-----BEGIN CERTIFICATE-----\n";
+ os << IceInternal::Base64::encode(data);
+ os << "-----END CERTIFICATE-----\n";
+ return os.str();
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
CFDataRef exported;
OSStatus err = SecItemExport(_cert, kSecFormatPEMSequence, kSecItemPemArmour, 0, &exported);
if(err != noErr)
@@ -1170,7 +1422,7 @@ Certificate::encode() const
throw;
}
return s;
-#else
+#elif defined(ICE_USE_OPENSSL)
BIO* out = BIO_new(BIO_s_mem());
int i = PEM_write_bio_X509_AUX(out, _cert);
if(i <= 0)
@@ -1183,9 +1435,25 @@ Certificate::encode() const
string result = string(p->data, p->length);
BIO_free(out);
return result;
+#elif defined(ICE_OS_WINRT)
+ auto reader = Windows::Storage::Streams::DataReader::FromBuffer(_cert->GetCertificateBlob());
+ std::vector<unsigned char> data(reader->UnconsumedBufferLength);
+ if (!data.empty())
+ {
+ reader->ReadBytes(Platform::ArrayReference<unsigned char>(&data[0], data.size()));
+ }
+ ostringstream os;
+ os << "-----BEGIN CERTIFICATE-----\n";
+ os << IceInternal::Base64::encode(data);
+ os << "-----END CERTIFICATE-----\n";
+ return os.str();
+#else
+# error "Unknown platform"
#endif
}
+#if !defined(ICE_USE_SECURE_TRANSPORT_IOS)
+
bool
Certificate::checkValidity() const
{
@@ -1206,8 +1474,13 @@ Certificate::getNotAfter() const
return getX509Date(_cert, kSecOIDX509V1ValidityNotAfter);
#elif defined(ICE_USE_SCHANNEL)
return filetimeToTime(_certInfo->NotAfter);
-#else
+#elif defined(ICE_USE_OPENSSL)
return ASMUtcTimeToIceUtilTime(X509_get_notAfter(_cert));
+#elif defined(ICE_OS_WINRT)
+ // Convert 100ns time from January 1, 1601 to ms from January 1, 1970
+ return IceUtil::Time::milliSeconds(_cert->ValidTo.UniversalTime / TICKS_PER_MSECOND - MSECS_TO_EPOCH);
+#else
+# error "Unknown platform"
#endif
}
@@ -1218,15 +1491,25 @@ Certificate::getNotBefore() const
return getX509Date(_cert, kSecOIDX509V1ValidityNotBefore);
#elif defined(ICE_USE_SCHANNEL)
return filetimeToTime(_certInfo->NotBefore);
-#else
+#elif defined(ICE_USE_OPENSSL)
return ASMUtcTimeToIceUtilTime(X509_get_notBefore(_cert));
+#elif defined(ICE_OS_WINRT)
+ // Convert 100ns time from January 1, 1601 to ms from January 1, 1970
+ return IceUtil::Time::milliSeconds(_cert->ValidFrom.UniversalTime / TICKS_PER_MSECOND - MSECS_TO_EPOCH);
+#else
+# error "Unknown platform"
#endif
}
+#endif
+
string
Certificate::getSerialNumber() const
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ initializeAttributes();
+ return _serial;
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
return getX509String(_cert, kSecOIDX509V1SerialNumber);
#elif defined(ICE_USE_SCHANNEL)
ostringstream os;
@@ -1235,14 +1518,14 @@ Certificate::getSerialNumber() const
unsigned char c = _certInfo->SerialNumber.pbData[i];
os.fill('0');
os.width(2);
- os << hex << (int)c;
+ os << hex << static_cast<int>(c);
if(i)
{
os << ' ';
}
}
return IceUtilInternal::toUpper(os.str());
-#else
+#elif defined(ICE_USE_OPENSSL)
BIGNUM* bn = ASN1_INTEGER_to_BN(X509_get_serialNumber(_cert), 0);
char* dec = BN_bn2dec(bn);
string result = dec;
@@ -1250,31 +1533,40 @@ Certificate::getSerialNumber() const
BN_free(bn);
return result;
+#elif defined(ICE_OS_WINRT)
+ ostringstream os;
+ os.fill(0);
+ os.width(2);
+ for (unsigned int i = 0; i < _cert->SerialNumber->Length; i++)
+ {
+ os << hex << static_cast<int>(_cert->SerialNumber[i]);
+ }
+ return IceUtilInternal::toUpper(os.str());
+#else
+# error "Unknown platform"
#endif
}
-//string
-//Certificate::getSigAlgName() const
-//{
-//}
-
-//string
-//Certificate::getSigAlgOID() const
-//{
-//}
-
DistinguishedName
Certificate::getIssuerDN() const
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ initializeAttributes();
+ return _issuer ? DistinguishedName(_issuer) : DistinguishedName("");
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
return getX509Name(_cert, kSecOIDX509V1IssuerName);
#elif defined(ICE_USE_SCHANNEL)
return DistinguishedName(certNameToString(&_certInfo->Issuer));
-#else
+#elif defined(ICE_USE_OPENSSL)
return DistinguishedName(RFC2253::parseStrict(convertX509NameToString(X509_get_issuer_name(_cert))));
+#elif defined(ICE_OS_WINRT)
+ return DistinguishedName(IceUtil::wstringToString(_cert->Issuer->Data()));
+#else
+# error "Unknown platform"
#endif
}
+#if !defined(ICE_USE_SECURE_TRANSPORT_IOS)
vector<pair<int, string> >
Certificate::getIssuerAlternativeNames()
{
@@ -1282,23 +1574,45 @@ Certificate::getIssuerAlternativeNames()
return getX509AltName(_cert, kSecOIDIssuerAltName);
#elif defined(ICE_USE_SCHANNEL)
return certificateAltNames(_certInfo, szOID_ISSUER_ALT_NAME2);
-#else
+#elif defined(ICE_USE_OPENSSL)
return convertGeneralNames(reinterpret_cast<GENERAL_NAMES*>(X509_get_ext_d2i(_cert, NID_issuer_alt_name, 0, 0)));
+#elif defined(ICE_OS_WINRT)
+ return vector<pair<int, string> >(); // Not supported
+#else
+# error "Unknown platform"
#endif
}
+#endif
DistinguishedName
Certificate::getSubjectDN() const
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ initializeAttributes();
+ if(_subject)
+ {
+ return DistinguishedName(_subject);
+ }
+ else
+ {
+ string s = "CN=";
+ s += fromCFString(UniqueRef<CFStringRef>(SecCertificateCopySubjectSummary(_cert)).get());
+ return DistinguishedName(s);
+ }
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
return getX509Name(_cert, kSecOIDX509V1SubjectName);
#elif defined(ICE_USE_SCHANNEL)
return DistinguishedName(certNameToString(&_certInfo->Subject));
-#else
+#elif defined(ICE_USE_OPENSSL)
return DistinguishedName(RFC2253::parseStrict(convertX509NameToString(X509_get_subject_name(_cert))));
+#elif defined(ICE_OS_WINRT)
+ return DistinguishedName(IceUtil::wstringToString(_cert->Subject->Data()));
+#else
+# error "Unknown platform"
#endif
}
+#if !defined(ICE_USE_SECURE_TRANSPORT_IOS)
vector<pair<int, string> >
Certificate::getSubjectAlternativeNames()
{
@@ -1306,20 +1620,32 @@ Certificate::getSubjectAlternativeNames()
return getX509AltName(_cert, kSecOIDSubjectAltName);
#elif defined(ICE_USE_SCHANNEL)
return certificateAltNames(_certInfo, szOID_SUBJECT_ALT_NAME2);
-#else
+#elif defined(ICE_USE_OPENSSL)
return convertGeneralNames(reinterpret_cast<GENERAL_NAMES*>(X509_get_ext_d2i(_cert, NID_subject_alt_name, 0, 0)));
+#elif defined(ICE_OS_WINRT)
+ return certificateAltNames(_cert->SubjectAlternativeName);
+#else
+# error "Unknown platform"
#endif
}
+#endif
int
Certificate::getVersion() const
{
-#if defined(ICE_USE_SECURE_TRANSPORT)
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ initializeAttributes();
+ return _version;
+#elif defined(ICE_USE_SECURE_TRANSPORT_MACOS)
return atoi(getX509String(_cert, kSecOIDX509V1Version).c_str()) - 1;
#elif defined(ICE_USE_SCHANNEL)
return _certInfo->dwVersion;
-#else
+#elif defined(ICE_USE_OPENSSL)
return static_cast<int>(X509_get_version(_cert));
+#elif defined(ICE_OS_WINRT)
+ return -1; // Not supported
+#else
+# error "Unknown platform"
#endif
}
@@ -1330,8 +1656,10 @@ Certificate::toString() const
os << "serial: " << getSerialNumber() << "\n";
os << "issuer: " << string(getIssuerDN()) << "\n";
os << "subject: " << string(getSubjectDN()) << "\n";
+#if !defined(ICE_USE_SECURE_TRANSPORT_IOS)
os << "notBefore: " << getNotBefore().toDateTime() << "\n";
os << "notAfter: " << getNotAfter().toDateTime();
+#endif
return os.str();
}
@@ -1340,3 +1668,101 @@ Certificate::getCert() const
{
return _cert;
}
+
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+
+namespace
+{
+
+IceUtil::Mutex* globalMutex = 0;
+
+class Init
+{
+public:
+
+ Init()
+ {
+ globalMutex = new IceUtil::Mutex;
+ }
+
+ ~Init()
+ {
+ delete globalMutex;
+ globalMutex = 0;
+ }
+};
+
+Init init;
+
+}
+
+void
+Certificate::initializeAttributes() const
+{
+ if(_subject)
+ {
+ return;
+ }
+
+ //
+ // We need to temporarily add the certificate to the keychain in order to
+ // retrieve its attributes. Unfortunately kSecMatchItemList doesn't work
+ // on iOS. We make sure only one thread adds/removes a cert at a time here.
+ //
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex);
+
+ CFMutableDictionaryRef query;
+
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecValueRef, _cert);
+ CFDictionarySetValue(query, kSecReturnAttributes, kCFBooleanTrue);
+ CFDictionaryRef attributes;
+ OSStatus err;
+ if((err = SecItemAdd(query, (CFTypeRef*)&attributes)) == errSecDuplicateItem)
+ {
+ CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
+ err = SecItemCopyMatching(query, (CFTypeRef*)&attributes);
+ }
+ else
+ {
+ CFRelease(query);
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
+ CFDictionarySetValue(query, kSecValueRef, _cert);
+ err = SecItemDelete(query);
+ }
+ CFRelease(query);
+ if(err != noErr)
+ {
+ _subject = 0;
+ _issuer = 0;
+ return;
+ }
+
+ _subject = (CFDataRef)CFDictionaryGetValue(attributes, kSecAttrSubject);
+ _issuer = (CFDataRef)CFDictionaryGetValue(attributes, kSecAttrIssuer);
+ CFDataRef serial = (CFDataRef)CFDictionaryGetValue(attributes, kSecAttrSerialNumber);
+ ostringstream os;
+ for(int i = 0; i < CFDataGetLength(serial); ++i)
+ {
+ int c = static_cast<int>(CFDataGetBytePtr(serial)[i]);
+ if(i)
+ {
+ os << ' ';
+ }
+ os.fill('0');
+ os.width(2);
+ os << hex << c;
+ }
+ _serial = os.str();
+ CFNumberRef version = (CFNumberRef)CFDictionaryGetValue(attributes, kSecAttrCertificateType);
+ if(!CFNumberGetValue(version, kCFNumberIntType, &_version))
+ {
+ _version = -1;
+ }
+ CFRetain(_subject);
+ CFRetain(_issuer);
+
+ CFRelease(attributes);
+}
+#endif \ No newline at end of file
diff --git a/cpp/src/IceSSL/ConnectorI.cpp b/cpp/src/IceSSL/ConnectorI.cpp
index 51a79e1929f..532847ec0ed 100644
--- a/cpp/src/IceSSL/ConnectorI.cpp
+++ b/cpp/src/IceSSL/ConnectorI.cpp
@@ -13,6 +13,7 @@
#include <IceSSL/OpenSSLTransceiverI.h>
#include <IceSSL/SecureTransportTransceiverI.h>
#include <IceSSL/SChannelTransceiverI.h>
+#include <IceSSL/WinRTTransceiverI.h>
#include <IceSSL/EndpointI.h>
#include <IceSSL/Util.h>
@@ -39,20 +40,19 @@ IceSSL::ConnectorI::connect()
throw ex;
}
- IceInternal::StreamSocketPtr stream = new IceInternal::StreamSocket(_instance, _proxy, _addr, _sourceAddr);
- return new TransceiverI(_instance, stream, _host, false);
+ return new TransceiverI(_instance, _delegate->connect(), _host, false);
}
Short
IceSSL::ConnectorI::type() const
{
- return _instance->type();
+ return _delegate->type();
}
string
IceSSL::ConnectorI::toString() const
{
- return IceInternal::addrToString(!_proxy ? _addr : _proxy->getAddress());
+ return _delegate->toString();
}
bool
@@ -64,22 +64,12 @@ IceSSL::ConnectorI::operator==(const IceInternal::Connector& r) const
return false;
}
- if(IceInternal::compareAddress(_addr, p->_addr) != 0)
+ if(this == p)
{
- return false;
- }
-
- if(_timeout != p->_timeout)
- {
- return false;
- }
-
- if(IceInternal::compareAddress(_sourceAddr, p->_sourceAddr) != 0)
- {
- return false;
+ return true;
}
- if(_connectionId != p->_connectionId)
+ if(_delegate != p->_delegate)
{
return false;
}
@@ -102,47 +92,25 @@ IceSSL::ConnectorI::operator<(const IceInternal::Connector& r) const
return type() < r.type();
}
- if(_timeout < p->_timeout)
- {
- return true;
- }
- else if(p->_timeout < _timeout)
- {
- return false;
- }
-
- int rc = compareAddress(_sourceAddr, p->_sourceAddr);
- if(rc < 0)
- {
- return true;
- }
- else if(rc > 0)
+ if(this == p)
{
return false;
}
- if(_connectionId < p->_connectionId)
+ if(_delegate < p->_delegate)
{
return true;
}
- else if(p->_connectionId < _connectionId)
+ else if(p->_delegate < _delegate)
{
return false;
}
- return IceInternal::compareAddress(_addr, p->_addr) == -1;
+ return false;
}
-IceSSL::ConnectorI::ConnectorI(const InstancePtr& instance, const string& host, const IceInternal::Address& addr,
- 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)
+IceSSL::ConnectorI::ConnectorI(const InstancePtr& instance, const IceInternal::ConnectorPtr& del, const string& h) :
+ _instance(instance), _delegate(del), _host(h)
{
}
diff --git a/cpp/src/IceSSL/ConnectorI.h b/cpp/src/IceSSL/ConnectorI.h
index 48a80fdebcc..e1434d97d1b 100644
--- a/cpp/src/IceSSL/ConnectorI.h
+++ b/cpp/src/IceSSL/ConnectorI.h
@@ -36,19 +36,13 @@ public:
private:
- ConnectorI(const InstancePtr&, const std::string&, const IceInternal::Address&,
- const IceInternal::NetworkProxyPtr&, const IceInternal::Address&,
- Ice::Int, const std::string&);
+ ConnectorI(const InstancePtr&, const IceInternal::ConnectorPtr&, const std::string&);
virtual ~ConnectorI();
friend class EndpointI;
const InstancePtr _instance;
+ const IceInternal::ConnectorPtr _delegate;
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 0038cf9717f..1615b12d05d 100644
--- a/cpp/src/IceSSL/EndpointI.cpp
+++ b/cpp/src/IceSSL/EndpointI.cpp
@@ -17,101 +17,135 @@
#include <Ice/DefaultsAndOverrides.h>
#include <Ice/Object.h>
#include <Ice/HashUtil.h>
+#include <Ice/Comparable.h>
using namespace std;
using namespace Ice;
using namespace IceSSL;
-#ifndef ICE_CPP11_MAPPING
-IceUtil::Shared* IceSSL::upCast(EndpointI* p) { return p; }
-#endif
+namespace
+{
-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)
+Ice::IPEndpointInfoPtr
+getIPEndpointInfo(const Ice::EndpointInfoPtr& info)
{
+ for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPEndpointInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
}
-IceSSL::EndpointI::EndpointI(const InstancePtr& instance) :
- IceInternal::IPEndpointI(instance),
- _instance(instance),
- _timeout(instance->defaultTimeout()),
- _compress(false)
+}
+
+#ifndef ICE_CPP11_MAPPING
+IceUtil::Shared* IceSSL::upCast(EndpointI* p) { return p; }
+#endif
+
+IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const IceInternal::EndpointIPtr& del) :
+ _instance(instance), _delegate(del)
{
}
-IceSSL::EndpointI::EndpointI(const InstancePtr& instance, Ice::InputStream* s) :
- IPEndpointI(instance, s),
- _instance(instance),
- _timeout(-1),
- _compress(false)
+void
+IceSSL::EndpointI::streamWriteImpl(Ice::OutputStream* stream) const
{
- s->read(const_cast<Int&>(_timeout));
- s->read(const_cast<bool&>(_compress));
+ _delegate->streamWriteImpl(stream);
}
Ice::EndpointInfoPtr
IceSSL::EndpointI::getInfo() const
{
EndpointInfoPtr info = ICE_MAKE_SHARED(IceInternal::InfoI<EndpointInfo>, shared_from_this());
- fillEndpointInfo(info.get());
+ info->underlying = _delegate->getInfo();
+ info->compress = info->underlying->compress;
+ info->timeout = info->underlying->timeout;
return info;
}
-Ice::EndpointInfoPtr
-IceSSL::EndpointI::getWSInfo(const string& resource) const
+Ice::Short
+IceSSL::EndpointI::type() const
{
- WSSEndpointInfoPtr info = ICE_MAKE_SHARED(IceInternal::InfoI<WSSEndpointInfo>, shared_from_this());
- fillEndpointInfo(info.get());
- info->resource = resource;
- return info;
+ return _delegate->type();
+}
+
+const std::string&
+IceSSL::EndpointI::protocol() const
+{
+ return _delegate->protocol();
}
Int
IceSSL::EndpointI::timeout() const
{
- return _timeout;
+ return _delegate->timeout();
}
IceInternal::EndpointIPtr
IceSSL::EndpointI::timeout(Int timeout) const
{
- if(timeout == _timeout)
+ if(timeout == _delegate->timeout())
{
return shared_from_this();
}
else
{
- return ICE_MAKE_SHARED(EndpointI, _instance, _host, _port, _sourceAddr, timeout, _connectionId, _compress);
+ return ICE_MAKE_SHARED(EndpointI, _instance, _delegate->timeout(timeout));
+ }
+}
+
+const string&
+IceSSL::EndpointI::connectionId() const
+{
+ return _delegate->connectionId();
+}
+
+IceInternal::EndpointIPtr
+IceSSL::EndpointI::connectionId(const string& connectionId) const
+{
+ if(connectionId == _delegate->connectionId())
+ {
+ return shared_from_this();
+ }
+ else
+ {
+ return ICE_MAKE_SHARED(EndpointI, _instance, _delegate->connectionId(connectionId));
}
}
bool
IceSSL::EndpointI::compress() const
{
- return _compress;
+ return _delegate->compress();
}
IceInternal::EndpointIPtr
IceSSL::EndpointI::compress(bool compress) const
{
- if(compress == _compress)
+ if(compress == _delegate->compress())
{
return shared_from_this();
}
else
{
- return ICE_MAKE_SHARED(EndpointI, _instance, _host, _port, _sourceAddr, _timeout, _connectionId, compress);
+ return ICE_MAKE_SHARED(EndpointI, _instance, _delegate->compress(compress));
}
}
bool
IceSSL::EndpointI::datagram() const
{
- return false;
+ return _delegate->datagram();
+}
+
+bool
+IceSSL::EndpointI::secure() const
+{
+ return _delegate->secure();
}
IceInternal::TransceiverPtr
@@ -120,46 +154,90 @@ IceSSL::EndpointI::transceiver() const
return 0;
}
+void
+IceSSL::EndpointI::connectors_async(Ice::EndpointSelectionType selType,
+ const IceInternal::EndpointI_connectorsPtr& callback) const
+{
+ class CallbackI : public IceInternal::EndpointI_connectors
+ {
+ public:
+
+ CallbackI(const IceInternal::EndpointI_connectorsPtr& callback, const InstancePtr& instance,
+ const string& host) :
+ _callback(callback), _instance(instance), _host(host)
+ {
+ }
+
+ virtual void connectors(const vector<IceInternal::ConnectorPtr>& c)
+ {
+ vector<IceInternal::ConnectorPtr> connectors = c;
+ for(vector<IceInternal::ConnectorPtr>::iterator p = connectors.begin(); p != connectors.end(); ++p)
+ {
+ *p = new ConnectorI(_instance, *p, _host);
+ }
+ _callback->connectors(connectors);
+ }
+
+ virtual void exception(const Ice::LocalException& ex)
+ {
+ _callback->exception(ex);
+ }
+
+ private:
+
+ const IceInternal::EndpointI_connectorsPtr _callback;
+ const InstancePtr _instance;
+ const string _host;
+ };
+
+ IPEndpointInfoPtr info = getIPEndpointInfo(_delegate->getInfo());
+ _delegate->connectors_async(selType, ICE_MAKE_SHARED(CallbackI, callback, _instance, info ? info->host : string()));
+}
+
IceInternal::AcceptorPtr
IceSSL::EndpointI::acceptor(const string& adapterName) const
{
- return new AcceptorI(ICE_DYNAMIC_CAST(IceSSL::EndpointI, shared_from_this()), _instance, adapterName, _host, _port);
+ return new AcceptorI(shared_from_this(), _instance, _delegate->acceptor(adapterName), adapterName);
}
EndpointIPtr
-IceSSL::EndpointI::endpoint(const AcceptorIPtr& acceptor) const
+IceSSL::EndpointI::endpoint(const IceInternal::EndpointIPtr& delEndp) const
{
- return ICE_MAKE_SHARED(EndpointI, _instance, _host, acceptor->effectivePort(), _sourceAddr, _timeout, _connectionId, _compress);
+ return ICE_MAKE_SHARED(EndpointI, _instance, delEndp);
}
-string
-IceSSL::EndpointI::options() const
+vector<IceInternal::EndpointIPtr>
+IceSSL::EndpointI::expand() const
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
- ostringstream s;
- s << IPEndpointI::options();
-
- if(_timeout == -1)
+ vector<IceInternal::EndpointIPtr> endps = _delegate->expand();
+ for(vector<IceInternal::EndpointIPtr>::iterator p = endps.begin(); p != endps.end(); ++p)
{
- s << " -t infinite";
- }
- else
- {
- s << " -t " << _timeout;
+ *p = p->get() == _delegate.get() ? shared_from_this() : ICE_MAKE_SHARED(EndpointI, _instance, *p);
}
+ return endps;
+}
- if(_compress)
+bool
+IceSSL::EndpointI::equivalent(const IceInternal::EndpointIPtr& endpoint) const
+{
+ const EndpointI* endpointI = dynamic_cast<const EndpointI*>(endpoint.get());
+ if(!endpointI)
{
- s << " -z";
+ return false;
}
+ return _delegate->equivalent(endpointI->_delegate);
+}
+
+Ice::Int
+IceSSL::EndpointI::hash() const
+{
+ return _delegate->hash();
+}
- return s.str();
+string
+IceSSL::EndpointI::options() const
+{
+ return _delegate->options();
}
bool
@@ -169,11 +247,6 @@ IceSSL::EndpointI::operator==(const Ice::Endpoint& r) const
IceSSL::EndpointI::operator==(const Ice::LocalObject& r) const
#endif
{
- if(!IPEndpointI::operator==(r))
- {
- return false;
- }
-
const EndpointI* p = dynamic_cast<const EndpointI*>(&r);
if(!p)
{
@@ -185,12 +258,7 @@ IceSSL::EndpointI::operator==(const Ice::LocalObject& r) const
return true;
}
- if(_timeout != p->_timeout)
- {
- return false;
- }
-
- if(_compress != p->_compress)
+ if(!Ice::targetEquals(_delegate, p->_delegate))
{
return false;
}
@@ -221,119 +289,27 @@ IceSSL::EndpointI::operator<(const Ice::LocalObject& r) const
return false;
}
- if(_timeout < p->_timeout)
- {
- return true;
- }
- else if(p->_timeout < _timeout)
- {
- return false;
- }
-
- if(!_compress && p->_compress)
+ if(Ice::targetLess(_delegate, p->_delegate))
{
return true;
}
- else if(p->_compress < _compress)
+ else if (Ice::targetLess(p->_delegate, _delegate))
{
return false;
}
- return IPEndpointI::operator<(r);
-}
-
-void
-IceSSL::EndpointI::streamWriteImpl(Ice::OutputStream* s) const
-{
- IPEndpointI::streamWriteImpl(s);
- s->write(_timeout);
- s->write(_compress);
-}
-
-void
-IceSSL::EndpointI::hashInit(Ice::Int& h) const
-{
- IPEndpointI::hashInit(h);
- IceInternal::hashAdd(h, _timeout);
- IceInternal::hashAdd(h, _compress);
-}
-
-void
-IceSSL::EndpointI::fillEndpointInfo(IPEndpointInfo* info) const
-{
- IPEndpointI::fillEndpointInfo(info);
- info->timeout = _timeout;
- info->compress = _compress;
+ return false;
}
bool
IceSSL::EndpointI::checkOption(const string& option, const string& argument, const string& endpoint)
{
- if(IPEndpointI::checkOption(option, argument, endpoint))
- {
- return true;
- }
-
- switch(option[1])
- {
- case 't':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "no argument provided for -t option in endpoint " + endpoint;
- throw ex;
- }
-
- if(argument == "infinite")
- {
- const_cast<Int&>(_timeout) = -1;
- }
- else
- {
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof() || _timeout < 1)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
- throw ex;
- }
- }
- return true;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- return true;
- }
-
- default:
- {
- return false;
- }
- }
-}
-
-IceInternal::ConnectorPtr
-IceSSL::EndpointI::createConnector(const IceInternal::Address& address, const IceInternal::NetworkProxyPtr& proxy) const
-{
- return new ConnectorI(_instance, _host, address, proxy, _sourceAddr, _timeout, _connectionId);
-}
-
-IceInternal::IPEndpointIPtr
-IceSSL::EndpointI::createEndpoint(const string& host, int port, const string& connectionId) const
-{
- return ICE_MAKE_SHARED(EndpointI, _instance, host, port, _sourceAddr, _timeout, connectionId, _compress);
+ return false;
}
-IceSSL::EndpointFactoryI::EndpointFactoryI(const InstancePtr& instance) : _instance(instance)
+IceSSL::EndpointFactoryI::EndpointFactoryI(const InstancePtr& instance,
+ const IceInternal::EndpointFactoryPtr& delegate) :
+ _instance(instance), _delegate(delegate)
{
}
@@ -356,25 +332,26 @@ IceSSL::EndpointFactoryI::protocol() const
IceInternal::EndpointIPtr
IceSSL::EndpointFactoryI::create(vector<string>& args, bool oaEndpoint) const
{
- IceInternal::IPEndpointIPtr endpt = ICE_MAKE_SHARED(EndpointI, _instance);
- endpt->initWithOptions(args, oaEndpoint);
- return endpt;
+ return ICE_MAKE_SHARED(EndpointI, _instance, _delegate->create(args, oaEndpoint));
}
IceInternal::EndpointIPtr
IceSSL::EndpointFactoryI::read(Ice::InputStream* s) const
{
- return ICE_MAKE_SHARED(EndpointI, _instance, s);
+ return ICE_MAKE_SHARED(EndpointI, _instance, _delegate->read(s));
}
void
IceSSL::EndpointFactoryI::destroy()
{
+ _delegate->destroy();
_instance = 0;
}
IceInternal::EndpointFactoryPtr
-IceSSL::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& instance) const
+IceSSL::EndpointFactoryI::clone(const IceInternal::ProtocolInstancePtr& inst,
+ const IceInternal::EndpointFactoryPtr& delegate) const
{
- return new EndpointFactoryI(new Instance(_instance->engine(), instance->type(), instance->protocol()));
+ InstancePtr instance = new Instance(_instance->engine(), inst->type(), inst->protocol());
+ return new EndpointFactoryI(instance, delegate ? delegate : _delegate->clone(instance, 0));
}
diff --git a/cpp/src/IceSSL/EndpointI.h b/cpp/src/IceSSL/EndpointI.h
index 0aec468f9c7..fd122d7b146 100644
--- a/cpp/src/IceSSL/EndpointI.h
+++ b/cpp/src/IceSSL/EndpointI.h
@@ -13,7 +13,6 @@
#include <Ice/EndpointI.h>
#include <Ice/IPEndpointI.h>
#include <Ice/EndpointFactory.h>
-#include <Ice/WSEndpoint.h>
#include <IceSSL/InstanceF.h>
#include <IceSSL/EndpointInfo.h>
#include <Ice/Network.h>
@@ -21,28 +20,38 @@
namespace IceSSL
{
-class EndpointI : public IceInternal::IPEndpointI, public IceInternal::WSEndpointDelegate
+class EndpointI : public IceInternal::EndpointI, public Ice::EnableSharedFromThis<EndpointI>
{
public:
- EndpointI(const InstancePtr&, const std::string&, Ice::Int, const IceInternal::Address&, Ice::Int,
- const std::string&, bool);
- EndpointI(const InstancePtr&);
- EndpointI(const InstancePtr&, Ice::InputStream*);
+ EndpointI(const InstancePtr&, const IceInternal::EndpointIPtr&);
+
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual Ice::EndpointInfoPtr getInfo() const;
- virtual Ice::EndpointInfoPtr getWSInfo(const std::string&) const;
+ virtual Ice::Short type() const;
+ virtual const std::string& protocol() const;
virtual Ice::Int timeout() const;
virtual IceInternal::EndpointIPtr timeout(Ice::Int) const;
+ virtual const std::string& connectionId() const;
+ virtual IceInternal::EndpointIPtr connectionId(const ::std::string&) const;
virtual bool compress() const;
virtual IceInternal::EndpointIPtr compress(bool) const;
virtual bool datagram() const;
+ virtual bool secure() const;
virtual IceInternal::TransceiverPtr transceiver() const;
+ virtual void connectors_async(Ice::EndpointSelectionType, const IceInternal::EndpointI_connectorsPtr&) const;
virtual IceInternal::AcceptorPtr acceptor(const std::string&) const;
+
+ virtual std::vector<IceInternal::EndpointIPtr> expand() const;
+ virtual bool equivalent(const IceInternal::EndpointIPtr&) const;
+ virtual ::Ice::Int hash() const;
virtual std::string options() const;
+ EndpointIPtr endpoint(const IceInternal::EndpointIPtr&) const;
+
#ifdef ICE_CPP11_MAPPING
virtual bool operator==(const Ice::Endpoint&) const;
virtual bool operator<(const Ice::Endpoint&) const;
@@ -51,29 +60,17 @@ public:
virtual bool operator<(const Ice::LocalObject&) const;
#endif
- virtual EndpointIPtr endpoint(const AcceptorIPtr&) const;
-
- using IceInternal::IPEndpointI::connectionId;
-
protected:
- virtual void streamWriteImpl(Ice::OutputStream*) const;
- virtual void hashInit(Ice::Int&) const;
- virtual void fillEndpointInfo(Ice::IPEndpointInfo*) const;
virtual bool checkOption(const std::string&, const std::string&, const std::string&);
- virtual IceInternal::ConnectorPtr createConnector(const IceInternal::Address&,
- const IceInternal::NetworkProxyPtr&) const;
- virtual IceInternal::IPEndpointIPtr createEndpoint(const std::string&, int, const std::string&) const;
-
private:
//
// All members are const, because endpoints are immutable.
//
const InstancePtr _instance;
- const Ice::Int _timeout;
- const bool _compress;
+ const IceInternal::EndpointIPtr _delegate;
};
class EndpointFactoryI : public IceInternal::EndpointFactory
@@ -88,14 +85,16 @@ public:
virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const;
+ virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&,
+ const IceInternal::EndpointFactoryPtr&) const;
private:
- EndpointFactoryI(const InstancePtr&);
+ EndpointFactoryI(const InstancePtr&, const IceInternal::EndpointFactoryPtr&);
friend class PluginI;
InstancePtr _instance;
+ const IceInternal::EndpointFactoryPtr _delegate;
};
}
diff --git a/cpp/src/IceSSL/Instance.cpp b/cpp/src/IceSSL/Instance.cpp
index b7f9ce3fdf4..e37ab14a967 100644
--- a/cpp/src/IceSSL/Instance.cpp
+++ b/cpp/src/IceSSL/Instance.cpp
@@ -7,13 +7,8 @@
//
// **********************************************************************
-#include <IceUtil/Config.h>
-#ifdef _WIN32
-# include <winsock2.h>
-#endif
#include <IceSSL/Instance.h>
#include <IceSSL/SSLEngine.h>
-#include <Ice/Properties.h>
using namespace std;
using namespace Ice;
diff --git a/cpp/src/IceSSL/Instance.h b/cpp/src/IceSSL/Instance.h
index 6a4514de52b..d9a25482eb0 100644
--- a/cpp/src/IceSSL/Instance.h
+++ b/cpp/src/IceSSL/Instance.h
@@ -10,8 +10,8 @@
#ifndef ICE_SSL_INSTANCE_H
#define ICE_SSL_INSTANCE_H
-#include <IceSSL/InstanceF.h>
#include <Ice/ProtocolInstance.h>
+#include <IceSSL/InstanceF.h>
#include <IceSSL/SSLEngineF.h>
namespace IceSSL
@@ -24,12 +24,12 @@ public:
Instance(const SSLEnginePtr&, Ice::Short, const std::string&);
virtual ~Instance();
- SSLEnginePtr
+ SSLEnginePtr
engine() const
{
return _engine;
}
-
+
bool initialized() const;
private:
diff --git a/cpp/src/IceSSL/Makefile.mk b/cpp/src/IceSSL/Makefile.mk
index 3a6988f4879..0e2e3d00e94 100644
--- a/cpp/src/IceSSL/Makefile.mk
+++ b/cpp/src/IceSSL/Makefile.mk
@@ -11,10 +11,7 @@ $(project)_libraries := IceSSL
IceSSL_targetdir := $(libdir)
IceSSL_dependencies := Ice
-IceSSL_cppflags := -DICESSL_API_EXPORTS
-IceSSL_sliceflags := --include-dir IceSSL --dll-export ICESSL_API
-
-IceSSL[iphoneos]_excludes := $(wildcard $(addprefix $(currentdir)/,*.cpp))
-IceSSL[iphonesimulator]_excludes = $(IceSSL[iphoneos]_excludes)
+IceSSL_cppflags := -DICE_SSL_API_EXPORTS
+IceSSL_sliceflags := --include-dir IceSSL --dll-export ICE_SSL_API
projects += $(project)
diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp
index 2178c292ea0..de7fbb3ade6 100644
--- a/cpp/src/IceSSL/OpenSSLTransceiverI.cpp
+++ b/cpp/src/IceSSL/OpenSSLTransceiverI.cpp
@@ -79,16 +79,20 @@ IceSSL_opensslVerifyCallback(int ok, X509_STORE_CTX* ctx)
IceInternal::NativeInfoPtr
IceSSL::TransceiverI::getNativeInfo()
{
- return _stream;
+ return _delegate->getNativeInfo();
}
IceInternal::SocketOperation
IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::Buffer& writeBuffer)
{
- IceInternal::SocketOperation status = _stream->connect(readBuffer, writeBuffer);
- if(status != IceInternal::SocketOperationNone)
+ if(!_connected)
{
- return status;
+ IceInternal::SocketOperation status = _delegate->initialize(readBuffer, writeBuffer);
+ if(status != IceInternal::SocketOperationNone)
+ {
+ return status;
+ }
+ _connected = true;
}
if(!_ssl)
@@ -96,7 +100,9 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B
//
// This static_cast is necessary due to 64bit windows. There SOCKET is a non-int type.
//
- BIO* bio = BIO_new_socket(static_cast<int>(_stream->fd()), 0);
+ SOCKET fd = _delegate->getNativeInfo()->fd();
+ assert(fd != INVALID_SOCKET); // Underlying transport must be SOCKET based.
+ BIO* bio = BIO_new_socket(static_cast<int>(fd), 0);
if(!bio)
{
SecurityException ex(__FILE__, __LINE__);
@@ -231,15 +237,9 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B
}
case SSL_ERROR_SSL:
{
- IceInternal::Address remoteAddr;
- string desc = "<not available>";
- if(IceInternal::fdToRemoteAddress(_stream->fd(), remoteAddr))
- {
- desc = IceInternal::addrToString(remoteAddr);
- }
ostringstream ostr;
ostr << "SSL error occurred for new " << (_incoming ? "incoming" : "outgoing")
- << " connection:\nremote address = " << desc << "\n" << _engine->sslErrors();
+ << " connection:\nremote address = " << _delegate->toString() << "\n" << _engine->sslErrors();
ProtocolException ex(__FILE__, __LINE__);
ex.reason = ostr.str();
throw ex;
@@ -278,12 +278,7 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B
{
_verified = true;
}
-
-#ifdef ICE_CPP11_MAPPING
- _engine->verifyPeer(_stream->fd(), _host, dynamic_pointer_cast<NativeConnectionInfo>(getInfo()));
-#else
- _engine->verifyPeer(_stream->fd(), _host, NativeConnectionInfoPtr::dynamicCast(getInfo()));
-#endif
+ _engine->verifyPeer(_host, ICE_DYNAMIC_CAST(NativeConnectionInfo, getInfo()), toString());
if(_engine->securityTraceLevel() >= 1)
{
@@ -342,15 +337,15 @@ IceSSL::TransceiverI::close()
_ssl = 0;
}
- _stream->close();
+ _delegate->close();
}
IceInternal::SocketOperation
IceSSL::TransceiverI::write(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(!_connected)
{
- return _stream->write(buf);
+ return _delegate->write(buf);
}
if(buf.i == buf.b.end())
@@ -450,9 +445,9 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf)
IceInternal::SocketOperation
IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(!_connected)
{
- return _stream->read(buf);
+ return _delegate->read(buf);
}
//
@@ -466,7 +461,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
return IceInternal::SocketOperationNone;
}
- _stream->ready(IceInternal::SocketOperationRead, false);
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead, false);
//
// It's impossible for packetSize to be more than an Int.
@@ -560,7 +555,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
//
// Check if there's still buffered data to read, set the read ready status.
//
- _stream->ready(IceInternal::SocketOperationRead, SSL_pending(_ssl) > 0);
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead, SSL_pending(_ssl) > 0);
return IceInternal::SocketOperationNone;
}
@@ -574,7 +569,7 @@ IceSSL::TransceiverI::protocol() const
string
IceSSL::TransceiverI::toString() const
{
- return _stream->toString();
+ return _delegate->toString();
}
string
@@ -587,16 +582,19 @@ Ice::ConnectionInfoPtr
IceSSL::TransceiverI::getInfo() const
{
NativeConnectionInfoPtr info = ICE_MAKE_SHARED(NativeConnectionInfo);
- fillConnectionInfo(info, info->nativeCerts);
- return info;
-}
-
-Ice::ConnectionInfoPtr
-IceSSL::TransceiverI::getWSInfo(const Ice::HeaderDict& headers) const
-{
- WSSNativeConnectionInfoPtr info = ICE_MAKE_SHARED(WSSNativeConnectionInfo);
- fillConnectionInfo(info, info->nativeCerts);
- info->headers = headers;
+ info->underlying = _delegate->getInfo();
+ info->incoming = _incoming;
+ info->adapterName = _adapterName;
+ info->verified = _verified;
+ info->nativeCerts = _nativeCerts;
+ for(vector<CertificatePtr>::const_iterator p = _nativeCerts.begin(); p != _nativeCerts.end(); ++p)
+ {
+ info->certs.push_back((*p)->encode());
+ }
+ if(_ssl != 0)
+ {
+ info->cipher = SSL_get_cipher_name(_ssl); // Nothing needs to be free'd.
+ }
return info;
}
@@ -608,7 +606,7 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&)
void
IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize)
{
- _stream->setBufferSize(rcvSize, sndSize);
+ _delegate->setBufferSize(rcvSize, sndSize);
}
int
@@ -656,14 +654,15 @@ IceSSL::TransceiverI::verifyCallback(int ok, X509_STORE_CTX* c)
return 1;
}
-IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, const IceInternal::StreamSocketPtr& stream,
+IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance, const IceInternal::TransceiverPtr& delegate,
const string& hostOrAdapterName, bool incoming) :
_instance(instance),
_engine(OpenSSLEnginePtr::dynamicCast(instance->engine())),
_host(incoming ? "" : hostOrAdapterName),
_adapterName(incoming ? hostOrAdapterName : ""),
_incoming(incoming),
- _stream(stream),
+ _delegate(delegate),
+ _connected(false),
_verified(false),
_ssl(0)
{
@@ -673,30 +672,4 @@ IceSSL::TransceiverI::~TransceiverI()
{
}
-void
-IceSSL::TransceiverI::fillConnectionInfo(const ConnectionInfoPtr& info, std::vector<CertificatePtr>& nativeCerts) const
-{
- IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress,
- info->remotePort);
- if(_stream->fd() != INVALID_SOCKET)
- {
- info->rcvSize = IceInternal::getRecvBufferSize(_stream->fd());
- info->sndSize = IceInternal::getSendBufferSize(_stream->fd());
- }
- info->adapterName = _adapterName;
- info->incoming = _incoming;
- info->verified = _verified;
- nativeCerts = _nativeCerts;
- for(vector<CertificatePtr>::const_iterator p = _nativeCerts.begin(); p != _nativeCerts.end(); ++p)
- {
- info->certs.push_back((*p)->encode());
- }
- if(_ssl != 0)
- {
- info->cipher = SSL_get_cipher_name(_ssl); // Nothing needs to be free'd.
- }
- info->adapterName = _adapterName;
- info->incoming = _incoming;
-}
-
#endif
diff --git a/cpp/src/IceSSL/OpenSSLTransceiverI.h b/cpp/src/IceSSL/OpenSSLTransceiverI.h
index 8451db86b69..58459e804b9 100644
--- a/cpp/src/IceSSL/OpenSSLTransceiverI.h
+++ b/cpp/src/IceSSL/OpenSSLTransceiverI.h
@@ -32,7 +32,7 @@ namespace IceSSL
class ConnectorI;
class AcceptorI;
-class TransceiverI : public IceInternal::Transceiver, public IceInternal::WSTransceiverDelegate
+class TransceiverI : public IceInternal::Transceiver
{
public:
@@ -51,7 +51,6 @@ public:
virtual std::string toString() const;
virtual std::string toDetailedString() const;
virtual Ice::ConnectionInfoPtr getInfo() const;
- virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const;
virtual void checkSendSize(const IceInternal::Buffer&);
virtual void setBufferSize(int rcvSize, int sndSize);
@@ -59,11 +58,9 @@ public:
private:
- TransceiverI(const InstancePtr&, const IceInternal::StreamSocketPtr&, const std::string&, bool);
+ TransceiverI(const InstancePtr&, const IceInternal::TransceiverPtr&, const std::string&, bool);
virtual ~TransceiverI();
- void fillConnectionInfo(const ConnectionInfoPtr&, std::vector<CertificatePtr>&) const;
-
friend class ConnectorI;
friend class AcceptorI;
@@ -72,7 +69,8 @@ private:
const std::string _host;
const std::string _adapterName;
const bool _incoming;
- const IceInternal::StreamSocketPtr _stream;
+ const IceInternal::TransceiverPtr _delegate;
+ bool _connected;
bool _verified;
std::vector<CertificatePtr> _nativeCerts;
diff --git a/cpp/src/IceSSL/PluginI.cpp b/cpp/src/IceSSL/PluginI.cpp
index 7e9fb283783..cd6bbab1f53 100644..100755
--- a/cpp/src/IceSSL/PluginI.cpp
+++ b/cpp/src/IceSSL/PluginI.cpp
@@ -15,6 +15,7 @@
#include <Ice/ProtocolPluginFacade.h>
#include <Ice/ProtocolInstance.h>
#include <Ice/LocalException.h>
+#include <Ice/RegisterPlugins.h>
using namespace std;
using namespace Ice;
@@ -23,17 +24,12 @@ using namespace IceSSL;
//
// Plug-in factory function.
//
-extern "C"
-{
-
-ICE_SSL_API Ice::Plugin*
+extern "C" ICE_SSL_API Ice::Plugin*
createIceSSL(const CommunicatorPtr& communicator, const string& /*name*/, const StringSeq& /*args*/)
{
return new PluginI(communicator);
}
-}
-
namespace Ice
{
@@ -46,6 +42,15 @@ registerIceSSL(bool loadOnInitialize)
}
//
+// Objective-C function to allow Objective-C programs to register plugin.
+//
+extern "C" ICE_SSL_API void
+ICEregisterIceSSL(bool loadOnInitialize)
+{
+ Ice::registerIceSSL(loadOnInitialize);
+}
+
+//
// Plugin implementation.
//
IceSSL::PluginI::PluginI(const Ice::CommunicatorPtr& com)
@@ -54,6 +59,8 @@ IceSSL::PluginI::PluginI(const Ice::CommunicatorPtr& com)
_engine = new SecureTransportEngine(com);
#elif defined(ICE_USE_SCHANNEL)
_engine = new SChannelEngine(com);
+#elif defined(ICE_OS_WINRT)
+ _engine = new WinRTEngine(com);
#else
_engine = new OpenSSLEngine(com);
#endif
@@ -63,8 +70,31 @@ IceSSL::PluginI::PluginI(const Ice::CommunicatorPtr& com)
// than in initialize, because the communicator may need to
// interpret proxies before the plug-in is fully initialized.
//
- IceInternal::EndpointFactoryPtr sslFactory = new EndpointFactoryI(new Instance(_engine, EndpointType, "ssl"));
- IceInternal::getProtocolPluginFacade(com)->addEndpointFactory(sslFactory);
+ IceInternal::ProtocolPluginFacadePtr pluginFacade = IceInternal::getProtocolPluginFacade(com);
+
+ // SSL based on TCP
+ IceInternal::EndpointFactoryPtr tcp = pluginFacade->getEndpointFactory(TCPEndpointType);
+ if(tcp)
+ {
+ InstancePtr instance = new Instance(_engine, SSLEndpointType, "ssl");
+ pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, tcp->clone(instance, 0)));
+ }
+
+ // SSL based on Bluetooth
+ IceInternal::EndpointFactoryPtr bluetooth = pluginFacade->getEndpointFactory(BTEndpointType);
+ if(bluetooth)
+ {
+ InstancePtr instance = new Instance(_engine, BTSEndpointType, "bts");
+ pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, bluetooth->clone(instance, 0)));
+ }
+
+ // SSL based on iAP
+ IceInternal::EndpointFactoryPtr iap = pluginFacade->getEndpointFactory(iAPEndpointType);
+ if(iap)
+ {
+ InstancePtr instance = new Instance(_engine, iAPSEndpointType, "iaps");
+ pluginFacade->addEndpointFactory(new EndpointFactoryI(instance, iap->clone(instance, 0)));
+ }
}
void
diff --git a/cpp/src/IceSSL/PluginI.h b/cpp/src/IceSSL/PluginI.h
index e0c5a48120b..ea0cf344ab4 100644
--- a/cpp/src/IceSSL/PluginI.h
+++ b/cpp/src/IceSSL/PluginI.h
@@ -46,6 +46,8 @@ private:
SecureTransportEnginePtr _engine;
#elif defined(ICE_USE_SCHANNEL)
SChannelEnginePtr _engine;
+#elif defined(ICE_OS_WINRT)
+ WinRTEnginePtr _engine;
#else
OpenSSLEnginePtr _engine;
#endif
diff --git a/cpp/src/IceSSL/RFC2253.cpp b/cpp/src/IceSSL/RFC2253.cpp
index 7b46682f3c2..e4c57add13a 100644
--- a/cpp/src/IceSSL/RFC2253.cpp
+++ b/cpp/src/IceSSL/RFC2253.cpp
@@ -271,7 +271,7 @@ parseAttributeType(const string& data, size_t& pos)
//
// Here we must also check for "oid." and "OID." before parsing
// according to the ALPHA KEYCHAR* rule.
- //
+ //
// First the OID case.
//
if(IceUtilInternal::isDigit(data[pos]) ||
@@ -318,7 +318,7 @@ parseAttributeType(const string& data, size_t& pos)
result += data[pos];
++pos;
// 1* KEYCHAR
- while(pos < data.size() &&
+ while(pos < data.size() &&
(IceUtilInternal::isAlpha(data[pos]) || IceUtilInternal::isDigit(data[pos]) || data[pos] == '-'))
{
result += data[pos];
@@ -448,7 +448,7 @@ parsePair(const string& data, size_t& pos)
}
return parseHexPair(data, pos, false);
}
-
+
//
// RFC 2253
// hexpair = hexchar hexchar
diff --git a/cpp/src/IceSSL/SChannelTransceiverI.cpp b/cpp/src/IceSSL/SChannelTransceiverI.cpp
index b5eca20d632..d7555d545a9 100644
--- a/cpp/src/IceSSL/SChannelTransceiverI.cpp
+++ b/cpp/src/IceSSL/SChannelTransceiverI.cpp
@@ -208,7 +208,7 @@ getSecBufferWithType(const SecBufferDesc& desc, ULONG bufferType)
IceInternal::NativeInfoPtr
IceSSL::TransceiverI::getNativeInfo()
{
- return _stream;
+ return _delegate->getNativeInfo();
}
IceInternal::SocketOperation
@@ -624,13 +624,17 @@ IceSSL::TransceiverI::encryptMessage(IceInternal::Buffer& buffer)
IceInternal::SocketOperation
IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::Buffer& writeBuffer)
{
- IceInternal::SocketOperation op = _stream->connect(readBuffer, writeBuffer);
- if(op != IceInternal::SocketOperationNone)
+ if(_state == StateNotInitialized)
{
- return op;
+ IceInternal::SocketOperation op = _delegate->initialize(readBuffer, writeBuffer);
+ if(op != IceInternal::SocketOperationNone)
+ {
+ return op;
+ }
+ _state = StateHandshakeNotStarted;
}
- op = sslHandshake();
+ IceInternal::SocketOperation op = sslHandshake();
if(op != IceInternal::SocketOperationNone)
{
return op;
@@ -715,7 +719,7 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B
}
}
- _engine->verifyPeer(_stream->fd(), _host, ICE_DYNAMIC_CAST(NativeConnectionInfo, getInfo()));
+ _engine->verifyPeer(_host, ICE_DYNAMIC_CAST(NativeConnectionInfo, getInfo()), toString());
_state = StateHandshakeComplete;
if(_instance->engine()->securityTraceLevel() >= 1)
@@ -746,8 +750,8 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B
}
out << toString();
}
- _stream->ready(IceInternal::SocketOperationRead,
- !_readUnprocessed.b.empty() || _readBuffer.i != _readBuffer.b.begin());
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead,
+ !_readUnprocessed.b.empty() || _readBuffer.i != _readBuffer.b.begin());
return IceInternal::SocketOperationNone;
}
@@ -778,7 +782,7 @@ IceSSL::TransceiverI::close()
_credentialsInitialized = false;
}
- _stream->close();
+ _delegate->close();
//
// Clear the buffers now instead of waiting for destruction.
@@ -791,9 +795,9 @@ IceSSL::TransceiverI::close()
IceInternal::SocketOperation
IceSSL::TransceiverI::write(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(_state == StateNotInitialized)
{
- return _stream->write(buf);
+ return _delegate->write(buf);
}
if(buf.i == buf.b.end())
@@ -826,9 +830,9 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf)
IceInternal::SocketOperation
IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(_state == StateNotInitialized)
{
- return _stream->read(buf);
+ return _delegate->read(buf);
}
if(buf.i == buf.b.end())
@@ -837,7 +841,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
}
assert(_state == StateHandshakeComplete);
- _stream->ready(IceInternal::SocketOperationRead, false);
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead, false);
while(buf.i != buf.b.end())
{
if(_readUnprocessed.b.empty() && _readBuffer.i == _readBuffer.b.begin() && !readRaw(_readBuffer))
@@ -857,8 +861,8 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
buf.i += decrypted;
}
- _stream->ready(IceInternal::SocketOperationRead,
- !_readUnprocessed.b.empty() || _readBuffer.i != _readBuffer.b.begin());
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead,
+ !_readUnprocessed.b.empty() || _readBuffer.i != _readBuffer.b.begin());
return IceInternal::SocketOperationNone;
}
@@ -867,9 +871,9 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
bool
IceSSL::TransceiverI::startWrite(IceInternal::Buffer& buffer)
{
- if(!_stream->isConnected())
+ if(_state == StateNotInitialized)
{
- return _stream->startWrite(buffer);
+ return _delegate->startWrite(buffer);
}
if(_state == StateHandshakeComplete && _bufferedW == 0)
@@ -878,19 +882,19 @@ IceSSL::TransceiverI::startWrite(IceInternal::Buffer& buffer)
_bufferedW = encryptMessage(buffer);
}
- return _stream->startWrite(_writeBuffer);
+ return _delegate->startWrite(_writeBuffer) && _bufferedW == (buffer.b.end() - buffer.i);
}
void
IceSSL::TransceiverI::finishWrite(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(_state == StateNotInitialized)
{
- _stream->finishWrite(buf);
+ _delegate->finishWrite(buf);
return;
}
- _stream->finishWrite(_writeBuffer);
+ _delegate->finishWrite(_writeBuffer);
if(_writeBuffer.i != _writeBuffer.b.end())
{
return; // We're not finished yet with writing the write buffer.
@@ -906,36 +910,36 @@ IceSSL::TransceiverI::finishWrite(IceInternal::Buffer& buf)
void
IceSSL::TransceiverI::startRead(IceInternal::Buffer& buffer)
{
- if(!_stream->isConnected())
+ if(_state == StateNotInitialized)
{
- _stream->startRead(buffer);
+ _delegate->startRead(buffer);
return;
}
- _stream->startRead(_readBuffer);
+ _delegate->startRead(_readBuffer);
}
void
IceSSL::TransceiverI::finishRead(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(_state == StateNotInitialized)
{
- _stream->finishRead(buf);
+ _delegate->finishRead(buf);
return;
}
- _stream->finishRead(_readBuffer);
+ _delegate->finishRead(_readBuffer);
if(_state == StateHandshakeComplete)
{
size_t decrypted = decryptMessage(buf);
if(decrypted > 0)
{
buf.i += decrypted;
- _stream->ready(IceInternal::SocketOperationRead,
- !_readUnprocessed.b.empty() || _readBuffer.i != _readBuffer.b.begin());
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead,
+ !_readUnprocessed.b.empty() || _readBuffer.i != _readBuffer.b.begin());
}
else
{
- _stream->ready(IceInternal::SocketOperationRead, false);
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead, false);
}
}
}
@@ -950,7 +954,7 @@ IceSSL::TransceiverI::protocol() const
string
IceSSL::TransceiverI::toString() const
{
- return _stream->toString();
+ return _delegate->toString();
}
string
@@ -963,65 +967,10 @@ Ice::ConnectionInfoPtr
IceSSL::TransceiverI::getInfo() const
{
NativeConnectionInfoPtr info = ICE_MAKE_SHARED(NativeConnectionInfo);
- fillConnectionInfo(info, info->nativeCerts);
- return info;
-}
-
-Ice::ConnectionInfoPtr
-IceSSL::TransceiverI::getWSInfo(const Ice::HeaderDict& headers) const
-{
- WSSNativeConnectionInfoPtr info = ICE_MAKE_SHARED(WSSNativeConnectionInfo);
- fillConnectionInfo(info, info->nativeCerts);
- info->headers = headers;
- return info;
-}
-
-void
-IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&)
-{
-}
-
-void
-IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize)
-{
- _stream->setBufferSize(rcvSize, sndSize);
-}
-
-IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance,
- const IceInternal::StreamSocketPtr& stream,
- const string& hostOrAdapterName,
- bool incoming) :
- _instance(instance),
- _engine(SChannelEnginePtr::dynamicCast(instance->engine())),
- _host(incoming ? "" : hostOrAdapterName),
- _adapterName(incoming ? hostOrAdapterName : ""),
- _incoming(incoming),
- _stream(stream),
- _state(StateHandshakeNotStarted),
- _bufferedW(0),
- _sslInitialized(false),
- _credentialsInitialized(false),
- _verified(false)
-{
-}
-
-IceSSL::TransceiverI::~TransceiverI()
-{
-}
-
-void
-IceSSL::TransceiverI::fillConnectionInfo(const ConnectionInfoPtr& info, vector<CertificatePtr>& nativeCerts) const
-{
- IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress,
- info->remotePort);
- if(_stream->fd() != INVALID_SOCKET)
- {
- info->rcvSize = IceInternal::getRecvBufferSize(_stream->fd());
- info->sndSize = IceInternal::getSendBufferSize(_stream->fd());
- }
-
+ info->underlying = _delegate->getInfo();
+ info->incoming = _incoming;
+ info->adapterName = _adapterName;
info->verified = _verified;
-
if(_sslInitialized)
{
CtxtHandle* ssl = const_cast<CtxtHandle*>(&_ssl);
@@ -1056,7 +1005,7 @@ IceSSL::TransceiverI::fillConnectionInfo(const ConnectionInfoPtr& info, vector<C
}
CertificatePtr certificate = ICE_MAKE_SHARED(Certificate, cc);
- nativeCerts.push_back(certificate);
+ info->nativeCerts.push_back(certificate);
info->certs.push_back(certificate->encode());
}
CertFreeCertificateChain(certChain);
@@ -1080,24 +1029,53 @@ IceSSL::TransceiverI::fillConnectionInfo(const ConnectionInfoPtr& info, vector<C
IceUtilInternal::lastErrorToString());
}
}
+ return info;
+}
- info->adapterName = _adapterName;
- info->incoming = _incoming;
+void
+IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&)
+{
+}
+
+void
+IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize)
+{
+ _delegate->setBufferSize(rcvSize, sndSize);
+}
+
+IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance,
+ const IceInternal::TransceiverPtr& delegate,
+ const string& hostOrAdapterName,
+ bool incoming) :
+ _instance(instance),
+ _engine(SChannelEnginePtr::dynamicCast(instance->engine())),
+ _host(incoming ? "" : hostOrAdapterName),
+ _adapterName(incoming ? hostOrAdapterName : ""),
+ _incoming(incoming),
+ _delegate(delegate),
+ _state(StateNotInitialized),
+ _bufferedW(0),
+ _sslInitialized(false),
+ _credentialsInitialized(false),
+ _verified(false)
+{
+}
+IceSSL::TransceiverI::~TransceiverI()
+{
}
bool
IceSSL::TransceiverI::writeRaw(IceInternal::Buffer& buf)
{
- ssize_t ret = _stream->write(reinterpret_cast<const char*>(&*buf.i), buf.b.end() - buf.i);
- buf.i += ret;
+ _delegate->write(buf);
return buf.i == buf.b.end();
}
bool
IceSSL::TransceiverI::readRaw(IceInternal::Buffer& buf)
{
- ssize_t ret = _stream->read(reinterpret_cast<char*>(&*buf.i), buf.b.end() - buf.i);
- buf.i += ret;
- return ret > 0;
+ IceInternal::Buffer::Container::iterator p = buf.i;
+ _delegate->read(buf);
+ return buf.i != p;
}
#endif
diff --git a/cpp/src/IceSSL/SChannelTransceiverI.h b/cpp/src/IceSSL/SChannelTransceiverI.h
index b9d96b47eea..dc9d8030b61 100644
--- a/cpp/src/IceSSL/SChannelTransceiverI.h
+++ b/cpp/src/IceSSL/SChannelTransceiverI.h
@@ -43,7 +43,7 @@ namespace IceSSL
class ConnectorI;
class AcceptorI;
-class TransceiverI : public IceInternal::Transceiver, public IceInternal::WSTransceiverDelegate
+class TransceiverI : public IceInternal::Transceiver
{
public:
@@ -68,17 +68,14 @@ public:
virtual std::string toString() const;
virtual std::string toDetailedString() const;
virtual Ice::ConnectionInfoPtr getInfo() const;
- virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const;
virtual void checkSendSize(const IceInternal::Buffer&);
virtual void setBufferSize(int rcvSize, int sndSize);
private:
- TransceiverI(const InstancePtr&, const IceInternal::StreamSocketPtr&, const std::string&, bool);
+ TransceiverI(const InstancePtr&, const IceInternal::TransceiverPtr&, const std::string&, bool);
virtual ~TransceiverI();
- void fillConnectionInfo(const ConnectionInfoPtr&, std::vector<CertificatePtr>&) const;
-
IceInternal::SocketOperation sslHandshake();
size_t decryptMessage(IceInternal::Buffer&);
@@ -92,6 +89,7 @@ private:
enum State
{
+ StateNotInitialized,
StateHandshakeNotStarted,
StateHandshakeReadContinue,
StateHandshakeWriteContinue,
@@ -103,7 +101,7 @@ private:
const std::string _host;
const std::string _adapterName;
const bool _incoming;
- const IceInternal::StreamSocketPtr _stream;
+ const IceInternal::TransceiverPtr _delegate;
State _state;
//
diff --git a/cpp/src/IceSSL/SSLEngine.cpp b/cpp/src/IceSSL/SSLEngine.cpp
index 31bc4d54e3d..ed286df2b5b 100644
--- a/cpp/src/IceSSL/SSLEngine.cpp
+++ b/cpp/src/IceSSL/SSLEngine.cpp
@@ -115,23 +115,24 @@ IceSSL::SSLEngine::initialize()
// VerifyPeer determines whether certificate validation failures abort a connection.
//
_verifyPeer = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyPeer", 2);
-
+
if(_verifyPeer < 0 || _verifyPeer > 2)
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "IceSSL: invalid value for " + propPrefix + "VerifyPeer";
throw ex;
}
-
+
_securityTraceLevel = properties->getPropertyAsInt("IceSSL.Trace.Security");
_securityTraceCategory = "Security";
}
void
-IceSSL::SSLEngine::verifyPeer(SOCKET fd, const string& address, const NativeConnectionInfoPtr& info)
+IceSSL::SSLEngine::verifyPeer(const string& address, const NativeConnectionInfoPtr& info, const string& desc)
{
const CertificateVerifierPtr verifier = getCertificateVerifier();
-
+
+#if !defined(ICE_USE_SECURE_TRANSPORT_IOS)
//
// For an outgoing connection, we compare the proxy address (if any) against
// fields in the server's certificate (if any).
@@ -248,6 +249,7 @@ IceSSL::SSLEngine::verifyPeer(SOCKET fd, const string& address, const NativeConn
}
}
}
+#endif
if(_verifyDepthMax > 0 && static_cast<int>(info->certs.size()) > _verifyDepthMax)
{
@@ -258,19 +260,19 @@ IceSSL::SSLEngine::verifyPeer(SOCKET fd, const string& address, const NativeConn
string msg = ostr.str();
if(_securityTraceLevel >= 1)
{
- _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
+ _logger->trace(_securityTraceCategory, msg + "\n" + desc);
}
SecurityException ex(__FILE__, __LINE__);
ex.reason = msg;
throw ex;
}
- if(!_trustManager->verify(info))
+ if(!_trustManager->verify(info, desc))
{
string msg = string(info->incoming ? "incoming" : "outgoing") + " connection rejected by trust manager";
if(_securityTraceLevel >= 1)
{
- _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
+ _logger->trace(_securityTraceCategory, msg + "\n" + desc);
}
SecurityException ex(__FILE__, __LINE__);
ex.reason = msg;
@@ -282,7 +284,7 @@ IceSSL::SSLEngine::verifyPeer(SOCKET fd, const string& address, const NativeConn
string msg = string(info->incoming ? "incoming" : "outgoing") + " connection rejected by certificate verifier";
if(_securityTraceLevel >= 1)
{
- _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
+ _logger->trace(_securityTraceCategory, msg + "\n" + desc);
}
SecurityException ex(__FILE__, __LINE__);
ex.reason = msg;
diff --git a/cpp/src/IceSSL/SSLEngine.h b/cpp/src/IceSSL/SSLEngine.h
index 08b79e85bd5..25748c71c78 100644
--- a/cpp/src/IceSSL/SSLEngine.h
+++ b/cpp/src/IceSSL/SSLEngine.h
@@ -22,6 +22,7 @@
#if defined(ICE_USE_SECURE_TRANSPORT)
# include <Security/Security.h>
+# include <Security/SecureTransport.h>
#elif defined(ICE_USE_SCHANNEL)
//
@@ -72,7 +73,7 @@ public:
//
// Verify peer certificate
//
- void verifyPeer(SOCKET, const std::string&, const NativeConnectionInfoPtr&);
+ void verifyPeer(const std::string&, const NativeConnectionInfoPtr&, const std::string&);
CertificateVerifierPtr getCertificateVerifier() const;
PasswordPromptPtr getPasswordPrompt() const;
@@ -80,6 +81,7 @@ public:
std::string getPassword() const;
void setPassword(const std::string& password);
+ bool getCheckCertName() const { return _checkCertName; }
int getVerifyPeer() const { return _verifyPeer; }
int securityTraceLevel() const { return _securityTraceLevel; }
std::string securityTraceCategory() const { return _securityTraceCategory; }
@@ -120,7 +122,6 @@ public:
private:
void parseCiphers(const std::string&);
- SecKeychainRef openKeychain();
bool _initialized;
UniqueRef<CFArrayRef> _certificateAuthorities;
@@ -131,8 +132,9 @@ private:
std::string _defaultDir;
+#if TARGET_OS_IPHONE==0
std::vector<char> _dhParams;
-
+#endif
std::vector<SSLCipherSuite> _ciphers;
IceUtil::Mutex _mutex;
};
@@ -179,6 +181,7 @@ private:
# endif
#endif
+
class SChannelEngine : public SSLEngine
{
public:
@@ -219,7 +222,22 @@ private:
HCERTCHAINENGINE _chainEngine;
std::vector<ALG_ID> _ciphers;
};
+
+#elif defined(ICE_OS_WINRT)
+
+class WinRTEngine : public SSLEngine
+{
+public:
+
+ WinRTEngine(const Ice::CommunicatorPtr&);
+
+ virtual void initialize();
+ virtual bool initialized() const;
+ virtual void destroy();
+};
+
#else // OpenSSL
+
class OpenSSLEngine : public SSLEngine
{
public:
diff --git a/cpp/src/IceSSL/SSLEngineF.h b/cpp/src/IceSSL/SSLEngineF.h
index 6d9c7a1e284..61656a11d2a 100644
--- a/cpp/src/IceSSL/SSLEngineF.h
+++ b/cpp/src/IceSSL/SSLEngineF.h
@@ -19,20 +19,24 @@ namespace IceSSL
{
class SSLEngine;
-ICE_SSL_API IceUtil::Shared* upCast(IceSSL::SSLEngine*);
+ICE_SSL_API IceUtil::Shared* upCast(SSLEngine*);
typedef IceInternal::Handle<SSLEngine> SSLEnginePtr;
#if defined(ICE_USE_SECURE_TRANSPORT)
class SecureTransportEngine;
-ICE_SSL_API IceUtil::Shared* upCast(IceSSL::SecureTransportEngine*);
+ICE_SSL_API IceUtil::Shared* upCast(SecureTransportEngine*);
typedef IceInternal::Handle<SecureTransportEngine> SecureTransportEnginePtr;
#elif defined(ICE_USE_SCHANNEL)
class SChannelEngine;
-ICE_SSL_API IceUtil::Shared* upCast(IceSSL::SChannelEngine*);
+ICE_SSL_API IceUtil::Shared* upCast(SChannelEngine*);
typedef IceInternal::Handle<SChannelEngine> SChannelEnginePtr;
+#elif defined(ICE_OS_WINRT)
+class WinRTEngine;
+ICE_SSL_API IceUtil::Shared* upCast(WinRTEngine*);
+typedef IceInternal::Handle<WinRTEngine> WinRTEnginePtr;
#else // OpenSSL
class OpenSSLEngine;
-ICE_SSL_API IceUtil::Shared* upCast(IceSSL::OpenSSLEngine*);
+ICE_SSL_API IceUtil::Shared* upCast(OpenSSLEngine*);
typedef IceInternal::Handle<OpenSSLEngine> OpenSSLEnginePtr;
#endif
diff --git a/cpp/src/IceSSL/SecureTransportEngine.cpp b/cpp/src/IceSSL/SecureTransportEngine.cpp
index 00cb59d4c83..1876477794c 100644
--- a/cpp/src/IceSSL/SecureTransportEngine.cpp
+++ b/cpp/src/IceSSL/SecureTransportEngine.cpp
@@ -858,6 +858,9 @@ IceSSL::SecureTransportEngine::initialize()
string certFile = properties->getProperty("IceSSL.CertFile");
string keyFile = properties->getProperty("IceSSL.KeyFile");
string findCert = properties->getProperty("IceSSL.FindCert");
+ string keychain = properties->getProperty("IceSSL.Keychain");
+ string keychainPassword = properties->getProperty("IceSSL.KeychainPassword");
+
if(!certFile.empty())
{
vector<string> files;
@@ -903,10 +906,10 @@ IceSSL::SecureTransportEngine::initialize()
keyFile = resolved;
}
- UniqueRef<SecKeychainRef> kc(openKeychain());
try
{
- _chain.reset(loadCertificateChain(file, keyFile, kc.get(), password, passwordPrompt, passwordRetryMax));
+ _chain.reset(loadCertificateChain(file, keyFile, keychain, keychainPassword, password, passwordPrompt,
+ passwordRetryMax));
break;
}
catch(const CertificateReadException& ce)
@@ -924,57 +927,13 @@ IceSSL::SecureTransportEngine::initialize()
}
else if(!findCert.empty())
{
- UniqueRef<SecKeychainRef> kc(openKeychain());
- UniqueRef<SecCertificateRef> cert(findCertificate(kc.get(), findCert));
-
- //
- // Retrieve the certificate chain
- //
- UniqueRef<SecPolicyRef> policy(SecPolicyCreateSSL(true, 0));
- SecTrustRef trust = 0;
- OSStatus err = SecTrustCreateWithCertificates((CFArrayRef)cert.get(), policy.get(), &trust);
- if(err || !trust)
- {
- throw PluginInitializationException(__FILE__, __LINE__,
- "IceSSL: error creating trust object" +
- (err ? ":\n" + errorToString(err) : ""));
- }
- UniqueRef<SecTrustRef> v(trust);
-
- SecTrustResultType trustResult;
- if((err = SecTrustEvaluate(trust, &trustResult)))
- {
- throw PluginInitializationException(__FILE__, __LINE__,
- "IceSSL: error evaluating trust:\n" + errorToString(err));
- }
-
- int chainLength = SecTrustGetCertificateCount(trust);
- CFMutableArrayRef items = CFArrayCreateMutable(kCFAllocatorDefault, chainLength, &kCFTypeArrayCallBacks);
- for(int i = 0; i < chainLength; ++i)
- {
- CFArrayAppendValue(items, SecTrustGetCertificateAtIndex(trust, i));
- }
-
- //
- // Replace the first certificate in the chain with the
- // identity.
- //
- SecIdentityRef identity;
- err = SecIdentityCreateWithCertificate(kc.get(), cert.get(), &identity);
- if(err != noErr)
- {
- ostringstream os;
- os << "IceSSL: couldn't create identity for certificate found in the keychain:\n" << errorToString(err);
- throw PluginInitializationException(__FILE__, __LINE__, os.str());
- }
- CFArraySetValueAtIndex(items, 0, identity);
- CFRelease(identity);
- _chain.reset(items);
+ _chain.reset(findCertificateChain(keychain, keychainPassword, findCert));
}
//
// DiffieHellmanParams in DER format.
//
+#if defined(ICE_USE_SECURE_TRANSPORT_MACOS)
string dhFile = properties->getProperty("IceSSL.DHParams");
if(!dhFile.empty())
{
@@ -986,6 +945,7 @@ IceSSL::SecureTransportEngine::initialize()
readFile(resolved, _dhParams);
}
+#endif
//
// Establish the cipher list.
@@ -1086,6 +1046,7 @@ IceSSL::SecureTransportEngine::newContext(bool incoming)
}
}
+#if defined(ICE_USE_SECURE_TRANSPORT_MACOS)
if(!_dhParams.empty())
{
if((err = SSLSetDiffieHellmanParams(ssl, &_dhParams[0], _dhParams.size())))
@@ -1094,6 +1055,7 @@ IceSSL::SecureTransportEngine::newContext(bool incoming)
"IceSSL: unable to create the trust object:\n" + errorToString(err));
}
}
+#endif
}
if(_chain && (err = SSLSetCertificate(ssl, _chain.get())))
@@ -1318,92 +1280,5 @@ IceSSL::SecureTransportEngine::parseCiphers(const string& ciphers)
}
}
-SecKeychainRef
-SecureTransportEngine::openKeychain()
-{
- const PropertiesPtr properties = communicator()->getProperties();
-
- //
- // Open the application KeyChain or create it if the keychain doesn't exists
- //
- string keychainPath = properties->getProperty("IceSSL.Keychain");
- string keychainPassword = properties->getProperty("IceSSL.KeychainPassword");
-
- SecKeychainRef keychain = 0;
- OSStatus err = 0;
- if(keychainPath.empty())
- {
- if((err = SecKeychainCopyDefault(&keychain)))
- {
- throw PluginInitializationException(__FILE__, __LINE__,
- "IceSSL: unable to retrieve default keychain:\n" + errorToString(err));
- }
- }
- else
- {
- //
- // KeyChain path is relative to the current working directory.
- //
- if(!IceUtilInternal::isAbsolutePath(keychainPath))
- {
- string cwd;
- if(IceUtilInternal::getcwd(cwd) == 0)
- {
- keychainPath = string(cwd) + '/' + keychainPath;
- }
- }
-
- if((err = SecKeychainOpen(keychainPath.c_str(), &keychain)))
- {
- throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: unable to open keychain: `" +
- keychainPath + "'\n" + errorToString(err));
- }
- }
-
- UniqueRef<SecKeychainRef> k(keychain);
-
- SecKeychainStatus status;
- err = SecKeychainGetStatus(keychain, &status);
- if(err == noErr)
- {
- const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str();
- if((err = SecKeychainUnlock(keychain, keychainPassword.size(), pass, pass != 0)))
- {
- throw PluginInitializationException(__FILE__, __LINE__,
- "IceSSL: unable to unlock keychain:\n" + errorToString(err));
- }
- }
- else if(err == errSecNoSuchKeychain)
- {
- const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str();
- if((err = SecKeychainCreate(keychainPath.c_str(), keychainPassword.size(), pass, pass == 0, 0, &keychain)))
- {
- throw PluginInitializationException(__FILE__, __LINE__,
- "IceSSL: unable to create keychain:\n" + errorToString(err));
- }
- k.reset(keychain);
- }
- else
- {
- throw PluginInitializationException(__FILE__, __LINE__,
- "IceSSL: unable to open keychain:\n" + errorToString(err));
- }
-
- //
- // Set keychain settings to avoid keychain lock.
- //
- SecKeychainSettings settings;
- settings.version = SEC_KEYCHAIN_SETTINGS_VERS1;
- settings.lockOnSleep = FALSE;
- settings.useLockInterval = FALSE;
- settings.lockInterval = INT_MAX;
- if((err = SecKeychainSetSettings(keychain, &settings)))
- {
- throw PluginInitializationException(__FILE__, __LINE__,
- "IceSSL: error setting keychain settings:\n" + errorToString(err));
- }
-
- return k.release();
-}
#endif
diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp
index b043ef19713..f407e008913 100644
--- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp
+++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp
@@ -96,7 +96,8 @@ socketRead(SSLConnectionRef connection, void* data, size_t* length)
}
bool
-checkTrustResult(SecTrustRef trust, const SecureTransportEnginePtr& engine, const InstancePtr& instance)
+checkTrustResult(SecTrustRef trust, const SecureTransportEnginePtr& engine, const InstancePtr& instance,
+ const string& host)
{
OSStatus err = noErr;
SecTrustResultType trustResult = kSecTrustResultOtherError;
@@ -115,6 +116,28 @@ checkTrustResult(SecTrustRef trust, const SecureTransportEnginePtr& engine, cons
throw SecurityException(__FILE__, __LINE__, "IceSSL: handshake failure:\n" + errorToString(err));
}
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ if(engine->getCheckCertName() && !host.empty())
+ {
+ //
+ // Add SSL trust policy if we need to check the certificate name.
+ //
+ UniqueRef<SecPolicyRef> policy(SecPolicyCreateSSL(false, toCFString(host)));
+ CFArrayRef policies;
+ if((err = SecTrustCopyPolicies(trust, &policies)))
+ {
+ throw SecurityException(__FILE__, __LINE__, "IceSSL: handshake failure:\n" + errorToString(err));
+ }
+ UniqueRef<CFMutableArrayRef> newPolicies(CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, policies));
+ CFRelease(policies);
+ CFArrayAppendValue(newPolicies.get(), policy.release());
+ if((err = SecTrustSetPolicies(trust, newPolicies.release())))
+ {
+ throw SecurityException(__FILE__, __LINE__, "IceSSL: handshake failure:\n" + errorToString(err));
+ }
+ }
+#endif
+
//
// Evaluate the trust
//
@@ -171,18 +194,29 @@ checkTrustResult(SecTrustRef trust, const SecureTransportEnginePtr& engine, cons
IceInternal::NativeInfoPtr
IceSSL::TransceiverI::getNativeInfo()
{
- return _stream;
+ return _delegate->getNativeInfo();
}
IceInternal::SocketOperation
IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::Buffer& writeBuffer)
{
- IceInternal::SocketOperation status = _stream->connect(readBuffer, writeBuffer);
- if(status != IceInternal::SocketOperationNone)
+ if(!_connected)
{
- return status;
+ IceInternal::SocketOperation status = _delegate->initialize(readBuffer, writeBuffer);
+ if(status != IceInternal::SocketOperationNone)
+ {
+ return status;
+ }
+ _connected = true;
}
+ //
+ // Limit the size of packets passed to SSLWrite/SSLRead to avoid
+ // blocking and holding too much memory.
+ //
+ _maxSendPacketSize = std::max(512, IceInternal::getSendBufferSize(_delegate->getNativeInfo()->fd()));
+ _maxRecvPacketSize = std::max(512, IceInternal::getRecvBufferSize(_delegate->getNativeInfo()->fd()));
+
OSStatus err = 0;
if(!_ssl)
{
@@ -237,7 +271,7 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B
}
if(err == noErr)
{
- _verified = checkTrustResult(_trust, _engine, _instance);
+ _verified = checkTrustResult(_trust, _engine, _instance, _host);
continue; // Call SSLHandshake to resume the handsake.
}
// Let it fall through, this will raise a SecurityException with the SSLCopyPeerTrust error.
@@ -247,18 +281,12 @@ IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::B
throw ConnectionLostException(__FILE__, __LINE__, 0);
}
- IceInternal::Address remoteAddr;
- string desc = "<not available>";
- if(IceInternal::fdToRemoteAddress(_stream->fd(), remoteAddr))
- {
- desc = IceInternal::addrToString(remoteAddr);
- }
ostringstream os;
os << "IceSSL: ssl error occurred for new " << (_incoming ? "incoming" : "outgoing") << " connection:\n"
- << "remote address = " << desc << "\n" << errorToString(err);
+ << _delegate->toString() << "\n" << errorToString(err);
throw ProtocolException(__FILE__, __LINE__, os.str());
}
- _engine->verifyPeer(_stream->fd(), _host, ICE_DYNAMIC_CAST(NativeConnectionInfo, getInfo()));
+ _engine->verifyPeer(_host, ICE_DYNAMIC_CAST(NativeConnectionInfo, getInfo()), toString());
if(_instance->engine()->securityTraceLevel() >= 1)
{
@@ -317,15 +345,15 @@ IceSSL::TransceiverI::close()
_ssl = 0;
}
- _stream->close();
+ _delegate->close();
}
IceInternal::SocketOperation
IceSSL::TransceiverI::write(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(!_connected)
{
- return _stream->write(buf);
+ return _delegate->write(buf);
}
if(buf.i == buf.b.end())
@@ -402,9 +430,9 @@ IceSSL::TransceiverI::write(IceInternal::Buffer& buf)
IceInternal::SocketOperation
IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
{
- if(!_stream->isConnected())
+ if(!_connected)
{
- return _stream->read(buf);
+ return _delegate->read(buf);
}
if(buf.i == buf.b.end())
@@ -412,7 +440,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
return IceInternal::SocketOperationNone;
}
- _stream->ready(IceInternal::SocketOperationRead, false);
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead, false);
size_t packetSize = std::min(static_cast<size_t>(buf.b.end() - buf.i), _maxRecvPacketSize);
while(buf.i != buf.b.end())
@@ -471,7 +499,7 @@ IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
errno = err;
throw SocketException(__FILE__, __LINE__, IceInternal::getSocketErrno());
}
- _stream->ready(IceInternal::SocketOperationRead, buffered > 0);
+ _delegate->getNativeInfo()->ready(IceInternal::SocketOperationRead, buffered > 0);
return IceInternal::SocketOperationNone;
}
@@ -484,7 +512,7 @@ IceSSL::TransceiverI::protocol() const
string
IceSSL::TransceiverI::toString() const
{
- return _stream->toString();
+ return _delegate->toString();
}
string
@@ -497,16 +525,30 @@ Ice::ConnectionInfoPtr
IceSSL::TransceiverI::getInfo() const
{
NativeConnectionInfoPtr info = ICE_MAKE_SHARED(NativeConnectionInfo);
- fillConnectionInfo(info, info->nativeCerts);
- return info;
-}
+ info->underlying = _delegate->getInfo();
+ info->incoming = _incoming;
+ info->adapterName = _adapterName;
+ if(_ssl)
+ {
+ for(int i = 0, count = SecTrustGetCertificateCount(_trust); i < count; ++i)
+ {
+ SecCertificateRef cert = SecTrustGetCertificateAtIndex(_trust, i);
+ CFRetain(cert);
-Ice::ConnectionInfoPtr
-IceSSL::TransceiverI::getWSInfo(const Ice::HeaderDict& headers) const
-{
- WSSNativeConnectionInfoPtr info = ICE_MAKE_SHARED(WSSNativeConnectionInfo);
- fillConnectionInfo(info, info->nativeCerts);
- info->headers = headers;
+ CertificatePtr certificate = ICE_MAKE_SHARED(Certificate, cert);
+ info->nativeCerts.push_back(certificate);
+ info->certs.push_back(certificate->encode());
+ }
+
+ SSLCipherSuite cipher;
+ SSLGetNegotiatedCipher(_ssl, &cipher);
+ info->cipher = _engine->getCipherName(cipher);
+ info->verified = _verified;
+ }
+ else
+ {
+ info->verified = false;
+ }
return info;
}
@@ -518,11 +560,11 @@ IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&)
void
IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize)
{
- _stream->setBufferSize(rcvSize, sndSize);
+ _delegate->setBufferSize(rcvSize, sndSize);
}
IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance,
- const IceInternal::StreamSocketPtr& stream,
+ const IceInternal::TransceiverPtr& delegate,
const string& hostOrAdapterName,
bool incoming) :
_instance(instance),
@@ -530,61 +572,19 @@ IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance,
_host(incoming ? "" : hostOrAdapterName),
_adapterName(incoming ? hostOrAdapterName : ""),
_incoming(incoming),
- _stream(stream),
+ _delegate(delegate),
_ssl(0),
_trust(0),
+ _connected(false),
_verified(false),
_buffered(0)
{
- //
- // Limit the size of packets passed to SSLWrite/SSLRead to avoid
- // blocking and holding too much memory.
- //
- _maxSendPacketSize = std::max(512, IceInternal::getSendBufferSize(_stream->fd()));
- _maxRecvPacketSize = std::max(512, IceInternal::getRecvBufferSize(_stream->fd()));
}
IceSSL::TransceiverI::~TransceiverI()
{
}
-void
-IceSSL::TransceiverI::fillConnectionInfo(const ConnectionInfoPtr& info, std::vector<CertificatePtr>& nativeCerts) const
-{
- IceInternal::fdToAddressAndPort(_stream->fd(), info->localAddress, info->localPort, info->remoteAddress,
- info->remotePort);
- if(_stream->fd() != INVALID_SOCKET)
- {
- info->rcvSize = IceInternal::getRecvBufferSize(_stream->fd());
- info->sndSize = IceInternal::getSendBufferSize(_stream->fd());
- }
-
- if(_ssl)
- {
- for(int i = 0, count = SecTrustGetCertificateCount(_trust); i < count; ++i)
- {
- SecCertificateRef cert = SecTrustGetCertificateAtIndex(_trust, i);
- CFRetain(cert);
-
- CertificatePtr certificate = ICE_MAKE_SHARED(Certificate, cert);
- nativeCerts.push_back(certificate);
- info->certs.push_back(certificate->encode());
- }
-
- SSLCipherSuite cipher;
- SSLGetNegotiatedCipher(_ssl, &cipher);
- info->cipher = _engine->getCipherName(cipher);
- info->verified = _verified;
- }
- else
- {
- info->verified = false;
- }
-
- info->adapterName = _adapterName;
- info->incoming = _incoming;
-}
-
OSStatus
IceSSL::TransceiverI::writeRaw(const char* data, size_t* length) const
{
@@ -592,13 +592,15 @@ IceSSL::TransceiverI::writeRaw(const char* data, size_t* length) const
try
{
- ssize_t ret = _stream->write(data, *length);
- if(ret < *length)
+ IceInternal::Buffer buf(reinterpret_cast<const Ice::Byte*>(data), reinterpret_cast<const Ice::Byte*>(data) + *length);
+ IceInternal::SocketOperation op = _delegate->write(buf);
+ if(op == IceInternal::SocketOperationWrite)
{
- *length = static_cast<size_t>(ret);
+ *length = buf.i - buf.b.begin();
_flags |= SSLWantWrite;
return errSSLWouldBlock;
}
+ assert(op == IceInternal::SocketOperationNone);
}
catch(const Ice::ConnectionLostException&)
{
@@ -623,13 +625,15 @@ IceSSL::TransceiverI::readRaw(char* data, size_t* length) const
try
{
- ssize_t ret = _stream->read(data, *length);
- if(ret < *length)
+ IceInternal::Buffer buf(reinterpret_cast<Ice::Byte*>(data), reinterpret_cast<Ice::Byte*>(data) + *length);
+ IceInternal::SocketOperation op = _delegate->read(buf);
+ if(op == IceInternal::SocketOperationRead)
{
- *length = static_cast<size_t>(ret);
+ *length = buf.i - buf.b.begin();
_flags |= SSLWantRead;
return errSSLWouldBlock;
}
+ assert(op == IceInternal::SocketOperationNone);
}
catch(const Ice::ConnectionLostException&)
{
diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.h b/cpp/src/IceSSL/SecureTransportTransceiverI.h
index 68b0a677783..71a2a6c5f34 100644
--- a/cpp/src/IceSSL/SecureTransportTransceiverI.h
+++ b/cpp/src/IceSSL/SecureTransportTransceiverI.h
@@ -17,12 +17,11 @@
#include <Ice/Transceiver.h>
#include <Ice/Network.h>
-#include <Ice/StreamSocket.h>
-#include <Ice/WSTransceiver.h>
#ifdef ICE_USE_SECURE_TRANSPORT
#include <Security/Security.h>
+#include <Security/SecureTransport.h>
#include <CoreFoundation/CoreFoundation.h>
namespace IceSSL
@@ -31,7 +30,7 @@ namespace IceSSL
class ConnectorI;
class AcceptorI;
-class TransceiverI : public IceInternal::Transceiver, public IceInternal::WSTransceiverDelegate
+class TransceiverI : public IceInternal::Transceiver
{
public:
@@ -51,7 +50,6 @@ public:
virtual std::string toString() const;
virtual std::string toDetailedString() const;
virtual Ice::ConnectionInfoPtr getInfo() const;
- virtual Ice::ConnectionInfoPtr getWSInfo(const Ice::HeaderDict&) const;
virtual void checkSendSize(const IceInternal::Buffer&);
virtual void setBufferSize(int rcvSize, int sndSize);
@@ -60,11 +58,9 @@ public:
private:
- TransceiverI(const InstancePtr&, const IceInternal::StreamSocketPtr&, const std::string&, bool);
+ TransceiverI(const InstancePtr&, const IceInternal::TransceiverPtr&, const std::string&, bool);
virtual ~TransceiverI();
- void fillConnectionInfo(const ConnectionInfoPtr&, std::vector<CertificatePtr>&) const;
-
friend class ConnectorI;
friend class AcceptorI;
@@ -73,10 +69,11 @@ private:
const std::string _host;
const std::string _adapterName;
const bool _incoming;
- const IceInternal::StreamSocketPtr _stream;
+ const IceInternal::TransceiverPtr _delegate;
SSLContextRef _ssl;
SecTrustRef _trust;
+ bool _connected;
bool _verified;
size_t _buffered;
diff --git a/cpp/src/IceSSL/TrustManager.cpp b/cpp/src/IceSSL/TrustManager.cpp
index 0e60abb5a82..31b42291db3 100644
--- a/cpp/src/IceSSL/TrustManager.cpp
+++ b/cpp/src/IceSSL/TrustManager.cpp
@@ -62,7 +62,7 @@ TrustManager::TrustManager(const Ice::CommunicatorPtr& communicator) :
}
bool
-TrustManager::verify(const NativeConnectionInfoPtr& info)
+TrustManager::verify(const NativeConnectionInfoPtr& info, const std::string& desc)
{
list<list<DistinguishedName> > reject, accept;
@@ -139,19 +139,14 @@ TrustManager::verify(const NativeConnectionInfoPtr& info)
Ice::Trace trace(_communicator->getLogger(), "Security");
if(info->incoming)
{
- trace << "trust manager evaluating client:\n"
- << "subject = " << string(subject) << '\n'
- << "adapter = " << info->adapterName << '\n'
- << "local addr = " << info->localAddress << ":" << info->localPort << '\n'
- << "remote addr = " << info->remoteAddress << ":" << info->remotePort;
+ trace << "trust manager evaluating client:\n" << "subject = " << string(subject) << '\n'
+ << "adapter = " << info->adapterName << '\n';
}
else
{
- trace << "trust manager evaluating server:\n"
- << "subject = " << string(subject) << '\n'
- << "local addr = " << info->localAddress << ":" << info->localPort << '\n'
- << "remote addr = " << info->remoteAddress << ":" << info->remotePort;
+ trace << "trust manager evaluating server:\n" << "subject = " << string(subject) << '\n';
}
+ trace << desc;
}
//
diff --git a/cpp/src/IceSSL/TrustManager.h b/cpp/src/IceSSL/TrustManager.h
index a03c5d2a694..a99363baf05 100644
--- a/cpp/src/IceSSL/TrustManager.h
+++ b/cpp/src/IceSSL/TrustManager.h
@@ -25,7 +25,7 @@ public:
TrustManager(const Ice::CommunicatorPtr&);
- bool verify(const NativeConnectionInfoPtr&);
+ bool verify(const NativeConnectionInfoPtr&, const std::string&);
private:
diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp
index b55ca494233..9a5f6bce50e 100644..100755
--- a/cpp/src/IceSSL/Util.cpp
+++ b/cpp/src/IceSSL/Util.cpp
@@ -8,7 +8,7 @@
// **********************************************************************
#include <IceUtil/Config.h>
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(ICE_OS_WINRT)
# include <winsock2.h>
#endif
@@ -16,6 +16,7 @@
#include <IceUtil/FileUtil.h>
#include <IceUtil/StringUtil.h>
+#include <Ice/Base64.h>
#include <Ice/LocalException.h>
#include <Ice/Network.h>
#include <Ice/Object.h>
@@ -33,30 +34,7 @@ using namespace Ice;
using namespace IceUtil;
using namespace IceSSL;
-void
-IceSSL::readFile(const string& file, vector<char>& buffer)
-{
- IceUtilInternal::ifstream is(file, ios::in | ios::binary);
- if(!is.good())
- {
- throw CertificateReadException(__FILE__, __LINE__, "error opening file " + file);
- }
-
- is.seekg(0, is.end);
- buffer.resize(static_cast<int>(is.tellg()));
- is.seekg(0, is.beg);
-
- if(!buffer.empty())
- {
- is.read(&buffer[0], buffer.size());
- if(!is.good())
- {
- throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file);
- }
- }
-}
-
-#ifndef ICE_USE_OPENSSL
+#if !defined(ICE_USE_OPENSSL)
namespace
{
@@ -423,12 +401,14 @@ IceSSL::errorToString(OSStatus status)
{
ostringstream os;
os << "(error: " << status;
+#if defined(ICE_USE_SECURE_TRANSPORT_MACOS)
CFStringRef s = SecCopyErrorMessageString(status, 0);
if(s)
{
os << " description: " << fromCFString(s);
CFRelease(s);
}
+#endif
os << ")";
return os.str();
}
@@ -448,6 +428,7 @@ IceSSL::fromCFString(CFStringRef v)
return s;
}
+#if defined(ICE_USE_SECURE_TRANSPORT_MACOS)
CFDictionaryRef
IceSSL::getCertificateProperty(SecCertificateRef cert, CFTypeRef key)
{
@@ -471,10 +452,36 @@ IceSSL::getCertificateProperty(SecCertificateRef cert, CFTypeRef key)
CFRelease(values);
return property;
}
+#endif
namespace
{
+CFDataRef
+readCertFile(const string& file)
+{
+ IceUtilInternal::ifstream is(file, ios::in | ios::binary);
+ if(!is.good())
+ {
+ throw CertificateReadException(__FILE__, __LINE__, "error opening file " + file);
+ }
+
+ is.seekg(0, is.end);
+ size_t size = is.tellg();
+ is.seekg(0, is.beg);
+
+ CFMutableDataRef data = CFDataCreateMutable(kCFAllocatorDefault, size);
+ CFDataSetLength(data, size);
+ is.read(reinterpret_cast<char*>(CFDataGetMutableBytePtr(data)), size);
+ if(!is.good())
+ {
+ CFRelease(data);
+ throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file);
+ }
+ return data;
+}
+
+#if defined(ICE_USE_SECURE_TRANSPORT_MACOS)
//
// Check the certificate basic constraints to check if the certificate is marked as a CA.
//
@@ -506,12 +513,7 @@ CFArrayRef
loadKeychainItems(const string& file, SecExternalItemType type, SecKeychainRef keychain, const string& passphrase,
const PasswordPromptPtr& prompt, int retryMax)
{
- vector<char> buffer;
- readFile(file, buffer);
- UniqueRef<CFDataRef> data(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
- reinterpret_cast<const UInt8*>(&buffer[0]),
- buffer.size(),
- kCFAllocatorNull));
+ UniqueRef<CFDataRef> data(readCertFile(file));
SecItemImportExportKeyParameters params;
memset(&params, 0, sizeof(params));
@@ -591,14 +593,93 @@ loadKeychainItems(const string& file, SecExternalItemType type, SecKeychainRef k
return items;
}
+SecKeychainRef
+openKeychain(const std::string& path, const std::string& keychainPassword)
+{
+ string keychainPath = path;
+ SecKeychainRef keychain = 0;
+ OSStatus err = 0;
+ if(keychainPath.empty())
+ {
+ if((err = SecKeychainCopyDefault(&keychain)))
+ {
+ throw PluginInitializationException(__FILE__, __LINE__,
+ "IceSSL: unable to retrieve default keychain:\n" + errorToString(err));
+ }
+ }
+ else
+ {
+ //
+ // KeyChain path is relative to the current working directory.
+ //
+ if(!IceUtilInternal::isAbsolutePath(keychainPath))
+ {
+ string cwd;
+ if(IceUtilInternal::getcwd(cwd) == 0)
+ {
+ keychainPath = string(cwd) + '/' + keychainPath;
+ }
+ }
+
+ if((err = SecKeychainOpen(keychainPath.c_str(), &keychain)))
+ {
+ throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: unable to open keychain: `" +
+ keychainPath + "'\n" + errorToString(err));
+ }
+ }
+
+ UniqueRef<SecKeychainRef> k(keychain);
+
+ SecKeychainStatus status;
+ err = SecKeychainGetStatus(keychain, &status);
+ if(err == noErr)
+ {
+ const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str();
+ if((err = SecKeychainUnlock(keychain, keychainPassword.size(), pass, pass != 0)))
+ {
+ throw PluginInitializationException(__FILE__, __LINE__,
+ "IceSSL: unable to unlock keychain:\n" + errorToString(err));
+ }
+ }
+ else if(err == errSecNoSuchKeychain)
+ {
+ const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str();
+ if((err = SecKeychainCreate(keychainPath.c_str(), keychainPassword.size(), pass, pass == 0, 0, &keychain)))
+ {
+ throw PluginInitializationException(__FILE__, __LINE__,
+ "IceSSL: unable to create keychain:\n" + errorToString(err));
+ }
+ k.reset(keychain);
+ }
+ else
+ {
+ throw PluginInitializationException(__FILE__, __LINE__,
+ "IceSSL: unable to open keychain:\n" + errorToString(err));
+ }
+
+ //
+ // Set keychain settings to avoid keychain lock.
+ //
+ SecKeychainSettings settings;
+ settings.version = SEC_KEYCHAIN_SETTINGS_VERS1;
+ settings.lockOnSleep = FALSE;
+ settings.useLockInterval = FALSE;
+ settings.lockInterval = INT_MAX;
+ if((err = SecKeychainSetSettings(keychain, &settings)))
+ {
+ throw PluginInitializationException(__FILE__, __LINE__,
+ "IceSSL: error setting keychain settings:\n" + errorToString(err));
+ }
+
+ return k.release();
}
//
// Imports a certificate private key and optionally add it to a keychain.
//
SecIdentityRef
-IceSSL::loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRef keychain, const string& password,
- const PasswordPromptPtr& prompt, int retryMax)
+loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRef keychain, const string& password,
+ const PasswordPromptPtr& prompt, int retryMax)
{
//
// Check if we already imported the certificate
@@ -751,17 +832,139 @@ IceSSL::loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRe
}
return identity;
}
+#else
+
+CFArrayRef
+loadCerts(const string& file)
+{
+ UniqueRef<CFMutableArrayRef> certs(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
+ if(file.find(".pem") != string::npos)
+ {
+ vector<char> buffer;
+ readFile(file, buffer);
+ string strbuf(buffer.begin(), buffer.end());
+ string::size_type size, startpos, endpos = 0;
+ bool first = true;
+ while(true)
+ {
+ startpos = strbuf.find("-----BEGIN CERTIFICATE-----", endpos);
+ if(startpos != string::npos)
+ {
+ startpos += sizeof("-----BEGIN CERTIFICATE-----");
+ endpos = strbuf.find("-----END CERTIFICATE-----", startpos);
+ if(endpos == string::npos)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: certificate " + file + " is not a valid PEM-encoded certificate";
+ throw ex;
+ }
+ size = endpos - startpos;
+ }
+ else if(first)
+ {
+ startpos = 0;
+ endpos = string::npos;
+ size = strbuf.size();
+ }
+ else
+ {
+ break;
+ }
+
+ vector<unsigned char> data(IceInternal::Base64::decode(string(&buffer[startpos], size)));
+ UniqueRef<CFDataRef> certdata(CFDataCreate(kCFAllocatorDefault, &data[0], data.size()));
+ SecCertificateRef cert = SecCertificateCreateWithData(0, certdata.get());
+ if(!cert)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: certificate " + file + " is not a valid PEM-encoded certificate";
+ throw ex;
+ }
+ CFArrayAppendValue(certs.get(), cert);
+ CFRelease(cert);
+ first = false;
+ }
+ }
+ else
+ {
+ UniqueRef<CFDataRef> data(readCertFile(file));
+ SecCertificateRef cert = SecCertificateCreateWithData(0, data.get());
+ if(!cert)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: certificate " + file + " is not a valid DER-encoded certificate";
+ throw ex;
+ }
+ CFArrayAppendValue(certs.get(), cert);
+ CFRelease(cert);
+ }
+ return certs.release();
+}
+#endif
+
+}
//
// Imports a certificate (it might contain an identity or certificate depending on the format).
//
CFArrayRef
-IceSSL::loadCertificateChain(const string& file, const string& keyFile, SecKeychainRef keychain,
- const string& password, const PasswordPromptPtr& prompt, int retryMax)
+IceSSL::loadCertificateChain(const string& file, const string& keyFile, const std::string& keychainPath,
+ const string& keychainPassword, const string& password, const PasswordPromptPtr& prompt,
+ int retryMax)
{
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ UniqueRef<CFDataRef> cert(readCertFile(file));
+
+ UniqueRef<CFMutableDictionaryRef> settings(CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks));
+ CFArrayRef items = 0;
+ OSStatus err;
+ if(password.empty() && prompt)
+ {
+ int count = 0;
+ do
+ {
+ UniqueRef<CFStringRef> pass(toCFString(prompt->getPassword()));
+ CFDictionarySetValue(settings.get(), kSecImportExportPassphrase, pass.get());
+ err = SecPKCS12Import(cert.get(), settings.get(), &items);
+ ++count;
+ }
+ while(err == errSecAuthFailed && count < retryMax);
+ }
+ else
+ {
+ UniqueRef<CFStringRef> pass(toCFString(password));
+ CFDictionarySetValue(settings.get(), kSecImportExportPassphrase, pass.get());
+ err = SecPKCS12Import(cert.get(), settings.get(), &items);
+ }
+ if(err != noErr)
+ {
+ ostringstream os;
+ os << "IceSSL: unable to import certificate from file " << file << " (error = " << err << ")";
+ throw InitializationException(__FILE__, __LINE__, os.str());
+ }
+
+ UniqueRef<CFArrayRef> itemsHolder(items);;
+ for(int i = 0; i < CFArrayGetCount(items); ++i)
+ {
+ CFDictionaryRef dict = (CFDictionaryRef)CFArrayGetValueAtIndex(items, i);
+ SecIdentityRef identity = (SecIdentityRef)CFDictionaryGetValue(dict, kSecImportItemIdentity);
+ if(identity)
+ {
+ CFArrayRef certs = (CFArrayRef)CFDictionaryGetValue(dict, kSecImportItemCertChain);
+ CFMutableArrayRef a = CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, certs);
+ CFArraySetValueAtIndex(a, 0, identity);
+ return a;
+ }
+ }
+ ostringstream os;
+ os << "IceSSL: couldn't find identity in file " << file;
+ throw InitializationException(__FILE__, __LINE__, os.str());
+#else
+ UniqueRef<SecKeychainRef> keychain(openKeychain(keychainPath, keychainPassword));
if(keyFile.empty())
{
- return loadKeychainItems(file, kSecItemTypeUnknown, keychain, password, prompt, retryMax);
+ return loadKeychainItems(file, kSecItemTypeUnknown, keychain.get(), password, prompt, retryMax);
}
else
{
@@ -783,26 +986,37 @@ IceSSL::loadCertificateChain(const string& file, const string& keyFile, SecKeych
// add the certificate/key to the keychain if they aren't
// already present in the keychain.
//
- UniqueRef<SecIdentityRef> identity(loadPrivateKey(keyFile, cert, keychain, password, prompt, retryMax));
+ UniqueRef<SecIdentityRef> identity(loadPrivateKey(keyFile, cert, keychain.get(), password, prompt, retryMax));
CFMutableArrayRef a = CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, items.get());
CFArraySetValueAtIndex(a, 0, identity.get());
return a;
}
+#endif
}
SecCertificateRef
IceSSL::loadCertificate(const string& file)
{
- CFArrayRef items = loadKeychainItems(file, kSecItemTypeCertificate, 0, "", 0, 0);
- SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(items, 0);
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ UniqueRef<CFArrayRef> certs(loadCerts(file));
+ assert(CFArrayGetCount(certs.get()) > 0);
+ SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(certs.get(), 0);
+ CFRetain(cert);
+ return cert;
+#else
+ UniqueRef<CFArrayRef> items(loadKeychainItems(file, kSecItemTypeCertificate, 0, "", 0, 0));
+ SecCertificateRef cert = (SecCertificateRef)CFArrayGetValueAtIndex(items.get(), 0);
CFRetain(cert);
- CFRelease(items);
return cert;
+#endif
}
CFArrayRef
IceSSL::loadCACertificates(const string& file)
{
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ return loadCerts(file);
+#else
UniqueRef<CFArrayRef> items(loadKeychainItems(file, kSecItemTypeCertificate, 0, "", 0, 0));
CFMutableArrayRef certificateAuthorities = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
int count = CFArrayGetCount(items.get());
@@ -816,10 +1030,11 @@ IceSSL::loadCACertificates(const string& file)
}
}
return certificateAuthorities;
+#endif
}
-SecCertificateRef
-IceSSL::findCertificate(SecKeychainRef keychain, const string& value)
+CFArrayRef
+IceSSL::findCertificateChain(const std::string& keychainPath, const std::string& keychainPassword, const string& value)
{
//
// Search the keychain using key:value pairs. The following keys are supported:
@@ -836,17 +1051,20 @@ IceSSL::findCertificate(SecKeychainRef keychain, const string& value)
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
- const void* values[] = { keychain };
+#if defined(ICE_USE_SECURE_TRANSPORT_MACOS)
+ UniqueRef<SecKeychainRef> keychain(openKeychain(keychainPath, keychainPassword));
+ const void* values[] = { keychain.get() };
UniqueRef<CFArrayRef> searchList(CFArrayCreate(kCFAllocatorDefault, values, 1, &kCFTypeArrayCallBacks));
-
- CFDictionarySetValue(query.get(), kSecMatchLimit, kSecMatchLimitOne);
CFDictionarySetValue(query.get(), kSecMatchSearchList, searchList.get());
+#endif
+ CFDictionarySetValue(query.get(), kSecMatchLimit, kSecMatchLimitOne);
CFDictionarySetValue(query.get(), kSecClass, kSecClassCertificate);
CFDictionarySetValue(query.get(), kSecReturnRef, kCFBooleanTrue);
CFDictionarySetValue(query.get(), kSecMatchCaseInsensitive, kCFBooleanTrue);
size_t start = 0;
size_t pos;
+ bool valid = false;
while((pos = value.find(':', start)) != string::npos)
{
string field = IceUtilInternal::toUpper(IceUtilInternal::trim(value.substr(start, pos - start)));
@@ -906,6 +1124,7 @@ IceSSL::findCertificate(SecKeychainRef keychain, const string& value)
{
UniqueRef<CFStringRef> v(toCFString(arg));
CFDictionarySetValue(query.get(), field == "LABEL" ? kSecAttrLabel : kSecMatchSubjectContains, v.get());
+ valid = true;
}
else if(field == "SUBJECTKEYID" || field == "SERIAL")
{
@@ -917,10 +1136,11 @@ IceSSL::findCertificate(SecKeychainRef keychain, const string& value)
UniqueRef<CFDataRef> v(CFDataCreate(kCFAllocatorDefault, &buffer[0], buffer.size()));
CFDictionarySetValue(query.get(), field == "SUBJECTKEYID" ? kSecAttrSubjectKeyID : kSecAttrSerialNumber,
v.get());
+ valid = true;
}
}
- if(CFDictionaryGetCount(query.get()) == 5)
+ if(!valid)
{
throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: invalid value `" + value + "'");
}
@@ -932,7 +1152,92 @@ IceSSL::findCertificate(SecKeychainRef keychain, const string& value)
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: find certificate `" + value + "' failed:\n" + errorToString(err));
}
- return cert;
+
+ UniqueRef<SecCertificateRef> certHolder(cert);
+
+ //
+ // Retrieve the certificate chain
+ //
+ UniqueRef<SecPolicyRef> policy(SecPolicyCreateSSL(true, 0));
+ SecTrustRef trust = 0;
+ err = SecTrustCreateWithCertificates((CFArrayRef)cert, policy.get(), &trust);
+ if(err || !trust)
+ {
+ throw PluginInitializationException(__FILE__, __LINE__,
+ "IceSSL: error creating trust object" +
+ (err ? ":\n" + errorToString(err) : ""));
+ }
+ UniqueRef<SecTrustRef> v(trust);
+
+ SecTrustResultType trustResult;
+ if((err = SecTrustEvaluate(trust, &trustResult)))
+ {
+ throw PluginInitializationException(__FILE__, __LINE__,
+ "IceSSL: error evaluating trust:\n" + errorToString(err));
+ }
+
+ int chainLength = SecTrustGetCertificateCount(trust);
+ CFMutableArrayRef items = CFArrayCreateMutable(kCFAllocatorDefault, chainLength, &kCFTypeArrayCallBacks);
+ UniqueRef<CFMutableArrayRef> itemsHolder(items);
+ for(int i = 0; i < chainLength; ++i)
+ {
+ CFArrayAppendValue(items, SecTrustGetCertificateAtIndex(trust, i));
+ }
+
+ //
+ // Replace the first certificate in the chain with the
+ // identity.
+ //
+ SecIdentityRef identity;
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+
+ //
+ // SecIdentityCreateWithCertificate isn't supported on iOS so we lookup the identity
+ // using the certicate label. If the user added the identity with SecItemAdd the
+ // identity has the same label as the certificate.
+ //
+ query.reset(CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ CFDictionarySetValue(query.get(), kSecClass, kSecClassCertificate);
+ CFDictionarySetValue(query.get(), kSecValueRef, cert);
+ CFDictionarySetValue(query.get(), kSecReturnAttributes, kCFBooleanTrue);
+ CFDictionaryRef attributes;
+ err = SecItemCopyMatching(query.get(), (CFTypeRef*)&attributes);
+ if(err != noErr)
+ {
+ ostringstream os;
+ os << "IceSSL: couldn't create identity for certificate found in the keychain:\n" << errorToString(err);
+ throw PluginInitializationException(__FILE__, __LINE__, os.str());
+ }
+ UniqueRef<CFDictionaryRef> attributesHolder(attributes);
+
+ // Now lookup the identity with the label
+ query.reset(CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ CFDictionarySetValue(query.get(), kSecMatchLimit, kSecMatchLimitOne);
+ CFDictionarySetValue(query.get(), kSecClass, kSecClassIdentity);
+ CFDictionarySetValue(query.get(), kSecAttrLabel, (CFDataRef)CFDictionaryGetValue(attributes, kSecAttrLabel));
+ CFDictionarySetValue(query.get(), kSecReturnRef, kCFBooleanTrue);
+ err = SecItemCopyMatching(query.get(), (CFTypeRef*)&identity);
+ if(err == noErr)
+ {
+ SecCertificateRef cert2 = NULL;
+ if((err = SecIdentityCopyCertificate(identity, &cert2)) == noErr)
+ {
+ err = CFEqual(cert2, cert) ? noErr : errSecItemNotFound;
+ CFRelease(cert2);
+ }
+ }
+#else
+ err = SecIdentityCreateWithCertificate(keychain.get(), cert, &identity);
+#endif
+ if(err != noErr)
+ {
+ ostringstream os;
+ os << "IceSSL: couldn't create identity for certificate found in the keychain:\n" << errorToString(err);
+ throw PluginInitializationException(__FILE__, __LINE__, os.str());
+ }
+ CFArraySetValueAtIndex(items, 0, identity);
+ CFRelease(identity);
+ return itemsHolder.release();
}
#elif defined(ICE_USE_SCHANNEL)
@@ -1195,9 +1500,55 @@ IceSSL::findCertificates(const string& location, const string& name, const strin
}
#endif
+void
+IceSSL::readFile(const string& file, vector<char>& buffer)
+{
+ IceUtilInternal::ifstream is(file, ios::in | ios::binary);
+ if(!is.good())
+ {
+ throw CertificateReadException(__FILE__, __LINE__, "error opening file " + file);
+ }
+
+ is.seekg(0, is.end);
+ buffer.resize(static_cast<int>(is.tellg()));
+ is.seekg(0, is.beg);
+
+ if(!buffer.empty())
+ {
+ is.read(&buffer[0], buffer.size());
+ if(!is.good())
+ {
+ throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file);
+ }
+ }
+}
+
bool
IceSSL::checkPath(const string& path, const string& defaultDir, bool dir, string& resolved)
{
+#if defined(ICE_USE_SECURE_TRANSPORT_IOS)
+ CFURLRef url = 0;
+ CFBundleRef bundle = CFBundleGetMainBundle();
+ if(bundle)
+ {
+ CFStringRef resourceName = toCFString(path);
+ CFStringRef subDirName = toCFString(defaultDir);
+ url = CFBundleCopyResourceURL(bundle, resourceName, 0, subDirName);
+ CFRelease(resourceName);
+ CFRelease(subDirName);
+
+ UInt8 filePath[PATH_MAX];
+ if(CFURLGetFileSystemRepresentation(url, true, filePath, sizeof(filePath)))
+ {
+ string tmp = string(reinterpret_cast<char*>(filePath));
+ if((dir && IceUtilInternal::directoryExists(tmp)) || (!dir && IceUtilInternal::fileExists(tmp)))
+ {
+ resolved = tmp;
+ return true;
+ }
+ }
+ }
+#endif
if(IceUtilInternal::isAbsolutePath(path))
{
if((dir && IceUtilInternal::directoryExists(path)) || (!dir && IceUtilInternal::fileExists(path)))
diff --git a/cpp/src/IceSSL/Util.h b/cpp/src/IceSSL/Util.h
index 855e0ac71b8..3e98050ee35 100644
--- a/cpp/src/IceSSL/Util.h
+++ b/cpp/src/IceSSL/Util.h
@@ -150,27 +150,23 @@ toCFString(const std::string& s)
std::string errorToString(CFErrorRef);
std::string errorToString(OSStatus);
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
//
// Retrieve a certificate property
//
CFDictionaryRef getCertificateProperty(SecCertificateRef, CFTypeRef);
-
-//
-// Read a private key from an file and associate it to the given certificate.
-//
-SecIdentityRef loadPrivateKey(const std::string&, SecCertificateRef, SecKeychainRef, const std::string&,
- const PasswordPromptPtr&, int);
+#endif
//
// Read certificate from a file.
//
-CFArrayRef loadCertificateChain(const std::string&, const std::string&, SecKeychainRef, const std::string&,
- const PasswordPromptPtr&, int);
+CFArrayRef loadCertificateChain(const std::string&, const std::string&, const std::string&, const std::string&,
+ const std::string&, const PasswordPromptPtr&, int);
SecCertificateRef loadCertificate(const std::string&);
CFArrayRef loadCACertificates(const std::string&);
-SecCertificateRef findCertificate(SecKeychainRef, const std::string&);
+CFArrayRef findCertificateChain(const std::string&, const std::string&, const std::string&);
#elif defined(ICE_USE_SCHANNEL)
std::vector<PCCERT_CONTEXT>
diff --git a/cpp/src/IceSSL/WinRTEngine.cpp b/cpp/src/IceSSL/WinRTEngine.cpp
new file mode 100755
index 00000000000..7eb59f922a7
--- /dev/null
+++ b/cpp/src/IceSSL/WinRTEngine.cpp
@@ -0,0 +1,43 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceSSL/Config.h>
+
+#ifdef ICE_OS_WINRT
+
+#include <IceSSL/SSLEngine.h>
+#include <IceUtil/Shared.h>
+
+IceUtil::Shared* IceSSL::upCast(IceSSL::WinRTEngine* p) { return p; }
+
+using namespace IceSSL;
+
+WinRTEngine::WinRTEngine(const Ice::CommunicatorPtr& communicator) : SSLEngine(communicator)
+{
+
+}
+
+void
+WinRTEngine::initialize()
+{
+}
+
+bool
+WinRTEngine::initialized() const
+{
+ return true;
+}
+
+void
+WinRTEngine::destroy()
+{
+}
+
+#endif
+
diff --git a/cpp/src/IceSSL/WinRTTransceiverI.cpp b/cpp/src/IceSSL/WinRTTransceiverI.cpp
new file mode 100755
index 00000000000..be0d632eaf8
--- /dev/null
+++ b/cpp/src/IceSSL/WinRTTransceiverI.cpp
@@ -0,0 +1,199 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <IceSSL/Config.h>
+
+#ifdef ICE_OS_WINRT
+
+#include <IceSSL/WinRTTransceiverI.h>
+#include <IceSSL/Instance.h>
+#include <IceSSL/SSLEngine.h>
+
+using namespace std;
+using namespace Ice;
+using namespace IceSSL;
+
+using namespace Platform;
+using namespace Windows::Networking;
+using namespace Windows::Networking::Sockets;
+
+IceInternal::NativeInfoPtr
+IceSSL::TransceiverI::getNativeInfo()
+{
+ return _delegate->getNativeInfo();
+}
+
+IceInternal::SocketOperation
+IceSSL::TransceiverI::initialize(IceInternal::Buffer& readBuffer, IceInternal::Buffer& writeBuffer)
+{
+ if(!_connected)
+ {
+ IceInternal::SocketOperation status = _delegate->initialize(readBuffer, writeBuffer);
+ if(status != IceInternal::SocketOperationNone)
+ {
+ return status;
+ }
+ _connected = true;
+
+ //
+ // Continue connecting, this will call startWrite/finishWrite to upgrade the stream
+ // to SSL.
+ //
+ return IceInternal::SocketOperationConnect;
+ }
+ else if(!_upgraded)
+ {
+ _upgraded = true;
+ }
+ return IceInternal::SocketOperationNone;
+}
+
+IceInternal::SocketOperation
+#ifdef ICE_CPP11_MAPPING
+IceSSL::TransceiverI::closing(bool initiator, exception_ptr ex)
+#else
+IceSSL::TransceiverI::closing(bool initiator, const Ice::LocalException& ex)
+#endif
+{
+ return _delegate->closing(initiator, ex);
+}
+
+void
+IceSSL::TransceiverI::close()
+{
+ _delegate->close();
+}
+
+IceInternal::SocketOperation
+IceSSL::TransceiverI::write(IceInternal::Buffer& buf)
+{
+ return _delegate->write(buf);
+}
+
+IceInternal::SocketOperation
+IceSSL::TransceiverI::read(IceInternal::Buffer& buf)
+{
+ return _delegate->read(buf);
+}
+
+bool
+IceSSL::TransceiverI::startWrite(IceInternal::Buffer& buf)
+{
+ if(_connected && !_upgraded)
+ {
+ StreamSocket^ stream = safe_cast<StreamSocket^>(_delegate->getNativeInfo()->fd());
+ HostName^ host = ref new HostName(ref new String(IceUtil::stringToWstring(_host).c_str()));
+ try
+ {
+ Windows::Foundation::IAsyncAction^ action = stream->UpgradeToSslAsync(SocketProtectionLevel::Tls12, host);
+ getNativeInfo()->queueAction(IceInternal::SocketOperationWrite, action);
+ }
+ catch(Platform::Exception^ ex)
+ {
+ IceInternal::checkErrorCode(__FILE__, __LINE__, ex->HResult);
+ }
+ return true;
+ }
+ return _delegate->startWrite(buf);
+}
+
+void
+IceSSL::TransceiverI::finishWrite(IceInternal::Buffer& buf)
+{
+ if(_connected && !_upgraded)
+ {
+ IceInternal::AsyncInfo* asyncInfo = getNativeInfo()->getAsyncInfo(IceInternal::SocketOperationWrite);
+ if(asyncInfo->count == SOCKET_ERROR)
+ {
+ IceInternal::checkErrorCode(__FILE__, __LINE__, asyncInfo->error);
+ }
+ return;
+ }
+ _delegate->finishWrite(buf);
+}
+
+void
+IceSSL::TransceiverI::startRead(IceInternal::Buffer& buf)
+{
+ _delegate->startRead(buf);
+}
+
+void
+IceSSL::TransceiverI::finishRead(IceInternal::Buffer& buf)
+{
+ _delegate->finishRead(buf);
+}
+
+string
+IceSSL::TransceiverI::protocol() const
+{
+ return _instance->protocol();
+}
+
+string
+IceSSL::TransceiverI::toString() const
+{
+ return _delegate->toString();
+}
+
+string
+IceSSL::TransceiverI::toDetailedString() const
+{
+ return toString();
+}
+
+Ice::ConnectionInfoPtr
+IceSSL::TransceiverI::getInfo() const
+{
+ NativeConnectionInfoPtr info = ICE_MAKE_SHARED(NativeConnectionInfo);
+ StreamSocket^ stream = safe_cast<StreamSocket^>(_delegate->getNativeInfo()->fd());
+ info->nativeCerts.push_back(ICE_MAKE_SHARED(Certificate, stream->Information->ServerCertificate));
+ info->certs.push_back(info->nativeCerts.back()->encode());
+ for(auto iter = stream->Information->ServerIntermediateCertificates->First(); iter->HasCurrent; iter->MoveNext())
+ {
+ info->nativeCerts.push_back(ICE_MAKE_SHARED(Certificate, iter->Current));
+ info->certs.push_back(info->nativeCerts.back()->encode());
+ }
+ info->adapterName = _adapterName;
+ info->incoming = _incoming;
+ info->underlying = _delegate->getInfo();
+ return info;
+}
+
+void
+IceSSL::TransceiverI::checkSendSize(const IceInternal::Buffer&)
+{
+}
+
+void
+IceSSL::TransceiverI::setBufferSize(int rcvSize, int sndSize)
+{
+ _delegate->setBufferSize(rcvSize, sndSize);
+}
+
+IceSSL::TransceiverI::TransceiverI(const InstancePtr& instance,
+ const IceInternal::TransceiverPtr& delegate,
+ const string& hostOrAdapterName,
+ bool incoming) :
+ _instance(instance),
+ _engine(WinRTEnginePtr::dynamicCast(instance->engine())),
+ _host(incoming ? "" : hostOrAdapterName),
+ _adapterName(incoming ? hostOrAdapterName : ""),
+ _incoming(incoming),
+ _delegate(delegate),
+ _connected(false),
+ _upgraded(false)
+{
+}
+
+IceSSL::TransceiverI::~TransceiverI()
+{
+}
+
+#endif
diff --git a/cpp/src/IceSSL/WinRTTransceiverI.h b/cpp/src/IceSSL/WinRTTransceiverI.h
new file mode 100755
index 00000000000..d3994eb359a
--- /dev/null
+++ b/cpp/src/IceSSL/WinRTTransceiverI.h
@@ -0,0 +1,81 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef ICE_SSL_WINRT_TRANSCEIVER_I_H
+#define ICE_SSL_WINRT_TRANSCEIVER_I_H
+
+#include <IceSSL/Config.h>
+
+#ifdef ICE_OS_WINRT
+
+#include <IceSSL/InstanceF.h>
+#include <IceSSL/SSLEngineF.h>
+#include <IceSSL/Plugin.h>
+
+#include <Ice/Transceiver.h>
+#include <Ice/Network.h>
+
+namespace IceSSL
+{
+
+class ConnectorI;
+class AcceptorI;
+
+class TransceiverI : public IceInternal::Transceiver
+{
+public:
+
+ virtual IceInternal::NativeInfoPtr getNativeInfo();
+
+ virtual IceInternal::SocketOperation initialize(IceInternal::Buffer&, IceInternal::Buffer&);
+#ifdef ICE_CPP11_MAPPING
+ virtual IceInternal::SocketOperation closing(bool, std::exception_ptr);
+#else
+ virtual IceInternal::SocketOperation closing(bool, const Ice::LocalException&);
+#endif
+ virtual void close();
+ virtual IceInternal::SocketOperation write(IceInternal::Buffer&);
+ virtual IceInternal::SocketOperation read(IceInternal::Buffer&);
+ virtual bool startWrite(IceInternal::Buffer&);
+ virtual void finishWrite(IceInternal::Buffer&);
+ virtual void startRead(IceInternal::Buffer&);
+ virtual void finishRead(IceInternal::Buffer&);
+
+ virtual std::string protocol() const;
+ virtual std::string toString() const;
+ virtual std::string toDetailedString() const;
+ virtual Ice::ConnectionInfoPtr getInfo() const;
+ virtual void checkSendSize(const IceInternal::Buffer&);
+ virtual void setBufferSize(int rcvSize, int sndSize);
+
+private:
+
+ TransceiverI(const InstancePtr&, const IceInternal::TransceiverPtr&, const std::string&, bool);
+ virtual ~TransceiverI();
+
+ friend class ConnectorI;
+ friend class AcceptorI;
+
+ const InstancePtr _instance;
+ const WinRTEnginePtr _engine;
+ const std::string _host;
+ const std::string _adapterName;
+ const bool _incoming;
+ const IceInternal::TransceiverPtr _delegate;
+
+ bool _connected;
+ bool _upgraded;
+};
+typedef IceUtil::Handle<TransceiverI> TransceiverIPtr;
+
+}
+
+#endif
+
+#endif
diff --git a/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj b/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj
index 2b35204da8a..6b376e66034 100644
--- a/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj
+++ b/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj
@@ -136,10 +136,18 @@
<IceBuilder Include="..\..\..\..\..\slice\IceSSL\EndpointInfo.ice" />
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\uwp\AcceptorI.cpp" />
- <ClCompile Include="..\..\uwp\ConnectorI.cpp" />
- <ClCompile Include="..\..\uwp\EndpointI.cpp" />
- <ClCompile Include="..\..\uwp\TransceiverI.cpp" />
+ <ClCompile Include="..\..\AcceptorI.cpp" />
+ <ClCompile Include="..\..\Certificate.cpp" />
+ <ClCompile Include="..\..\ConnectorI.cpp" />
+ <ClCompile Include="..\..\EndpointI.cpp" />
+ <ClCompile Include="..\..\Instance.cpp" />
+ <ClCompile Include="..\..\PluginI.cpp" />
+ <ClCompile Include="..\..\RFC2253.cpp" />
+ <ClCompile Include="..\..\SSLEngine.cpp" />
+ <ClCompile Include="..\..\TrustManager.cpp" />
+ <ClCompile Include="..\..\Util.cpp" />
+ <ClCompile Include="..\..\WinRTEngine.cpp" />
+ <ClCompile Include="..\..\WinRTTransceiverI.cpp" />
<ClCompile Include="ARM\Debug\ConnectionInfo.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
diff --git a/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj.filters b/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj.filters
index 7d141e0bffd..17f262f778e 100644
--- a/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj.filters
+++ b/cpp/src/IceSSL/msbuild/icessluwp++11/icessluwp++11.vcxproj.filters
@@ -75,18 +75,6 @@
</IceBuilder>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\..\uwp\AcceptorI.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\uwp\ConnectorI.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\uwp\EndpointI.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\uwp\TransceiverI.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="Win32\Debug\ConnectionInfo.cpp">
<Filter>Source Files\Win32\Debug</Filter>
</ClCompile>
@@ -123,6 +111,40 @@
<ClCompile Include="x64\Release\EndpointInfo.cpp">
<Filter>Source Files\x64\Release</Filter>
</ClCompile>
+ <ClCompile Include="..\..\ConnectorI.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\AcceptorI.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\EndpointI.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Instance.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\SSLEngine.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\TrustManager.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\WinRTTransceiverI.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\PluginI.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Certificate.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\Util.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\WinRTEngine.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\RFC2253.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\uwp\AcceptorI.h">
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 81c335ad2dc..5fe808581fa 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -2527,7 +2527,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
bool hasBaseClass = !bases.empty() && !bases.front()->isInterface();
- bool override = p->canBeCyclic() && (!hasBaseClass || !bases.front()->canBeCyclic());
+ bool override = !p->isLocal() && p->canBeCyclic() && (!hasBaseClass || !bases.front()->canBeCyclic());
bool hasGCObjectBaseClass = basePreserved || override || preserved;
if(!basePreserved && (override || preserved))
{
diff --git a/cpp/test/Ice/background/EndpointFactory.cpp b/cpp/test/Ice/background/EndpointFactory.cpp
index 9cf7d4a16eb..bf1cb1422b0 100644
--- a/cpp/test/Ice/background/EndpointFactory.cpp
+++ b/cpp/test/Ice/background/EndpointFactory.cpp
@@ -56,7 +56,7 @@ EndpointFactory::destroy()
}
IceInternal::EndpointFactoryPtr
-EndpointFactory::clone(const IceInternal::ProtocolInstancePtr&) const
+EndpointFactory::clone(const IceInternal::ProtocolInstancePtr&, const IceInternal::EndpointFactoryPtr&) const
{
return const_cast<EndpointFactory*>(this);
}
diff --git a/cpp/test/Ice/background/EndpointFactory.h b/cpp/test/Ice/background/EndpointFactory.h
index 5f265996bd8..9dab2bac2ef 100644
--- a/cpp/test/Ice/background/EndpointFactory.h
+++ b/cpp/test/Ice/background/EndpointFactory.h
@@ -24,7 +24,8 @@ public:
virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const;
+ virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&,
+ const IceInternal::EndpointFactoryPtr&) const;
protected:
diff --git a/cpp/test/Ice/background/EndpointI.cpp b/cpp/test/Ice/background/EndpointI.cpp
index 6cd3550e563..76748bea94a 100644
--- a/cpp/test/Ice/background/EndpointI.cpp
+++ b/cpp/test/Ice/background/EndpointI.cpp
@@ -32,12 +32,10 @@ EndpointI::EndpointI(const IceInternal::EndpointIPtr& endpoint) :
}
void
-EndpointI::streamWrite(Ice::OutputStream* s) const
+EndpointI::streamWriteImpl(Ice::OutputStream* s) const
{
- s->startEncapsulation();
s->write(_endpoint->type());
_endpoint->streamWrite(s);
- s->endEncapsulation();
}
Ice::Short
diff --git a/cpp/test/Ice/background/EndpointI.h b/cpp/test/Ice/background/EndpointI.h
index ea9423331b6..2e8b823b7a4 100644
--- a/cpp/test/Ice/background/EndpointI.h
+++ b/cpp/test/Ice/background/EndpointI.h
@@ -23,11 +23,11 @@ class EndpointI : public IceInternal::EndpointI, public Ice::EnableSharedFromThi
public:
static Ice::Short TYPE_BASE;
-
+
EndpointI(const IceInternal::EndpointIPtr&);
// From EndpointI
- virtual void streamWrite(Ice::OutputStream*) const;
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual Ice::Short type() const;
virtual const std::string& protocol() const;
virtual IceInternal::EndpointIPtr timeout(Ice::Int) const;
diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp
index 81da1e2aafa..e9edf0327ee 100644
--- a/cpp/test/Ice/info/AllTests.cpp
+++ b/cpp/test/Ice/info/AllTests.cpp
@@ -15,6 +15,39 @@
using namespace std;
using namespace Test;
+namespace
+{
+
+Ice::TCPEndpointInfoPtr
+getTCPEndpointInfo(const Ice::EndpointInfoPtr& info)
+{
+ for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::TCPEndpointInfoPtr tcpInfo = ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, p);
+ if(tcpInfo)
+ {
+ return tcpInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+Ice::TCPConnectionInfoPtr
+getTCPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::TCPConnectionInfoPtr tcpInfo = ICE_DYNAMIC_CAST(Ice::TCPConnectionInfo, p);
+ if(tcpInfo)
+ {
+ return tcpInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
void
allTests(const Ice::CommunicatorPtr& communicator)
{
@@ -27,7 +60,8 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::EndpointSeq endps = p1->ice_getEndpoints();
- Ice::IPEndpointInfoPtr ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, endps[0]->getInfo());
+ Ice::EndpointInfoPtr info = endps[0]->getInfo();
+ Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(info);
test(ipEndpoint);
test(ipEndpoint->host == "tcphost");
test(ipEndpoint->port == 10000);
@@ -38,13 +72,14 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(ipEndpoint->compress);
test(!ipEndpoint->datagram());
test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) ||
- (ipEndpoint->type() == IceSSL::EndpointType && ipEndpoint->secure()) ||
+ (ipEndpoint->type() == Ice::SSLEndpointType && ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ipEndpoint->secure()));
- test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == IceSSL::EndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(IceSSL::WSSEndpointInfo, ipEndpoint)));
+
+ test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::SSLEndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)));
Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endps[1]->getInfo());
test(udpEndpoint);
@@ -81,9 +116,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
- Ice::IPEndpointInfoPtr ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, endpoints[0]->getInfo());
+ Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo());
test(ipEndpoint);
- test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == IceSSL::EndpointType ||
+ test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == Ice::SSLEndpointType ||
ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType);
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port > 0);
@@ -108,11 +143,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, (*p)->getInfo());
+ ipEndpoint = getTCPEndpointInfo((*p)->getInfo());
test(ipEndpoint->port == 12020);
}
- ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, publishedEndpoints[0]->getInfo());
+ ipEndpoint = getTCPEndpointInfo(publishedEndpoints[0]->getInfo());
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port == 12020);
@@ -126,15 +161,15 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "test connection endpoint information... " << flush;
{
Ice::EndpointInfoPtr info = base->ice_getConnection()->getEndpoint()->getInfo();
- Ice::IPEndpointInfoPtr ipinfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, info);
- test(ipinfo->port == 12010);
- test(!ipinfo->compress);
- test(ipinfo->host == defaultHost);
+ Ice::TCPEndpointInfoPtr tcpinfo = getTCPEndpointInfo(info);
+ test(tcpinfo->port == 12010);
+ test(!tcpinfo->compress);
+ test(tcpinfo->host == defaultHost);
ostringstream os;
Ice::Context ctx = testIntf->getEndpointInfoAsContext();
- test(ctx["host"] == ipinfo->host);
+ test(ctx["host"] == tcpinfo->host);
test(ctx["compress"] == "false");
istringstream is(ctx["port"]);
int port;
@@ -154,7 +189,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::ConnectionPtr connection = base->ice_getConnection();
connection->setBufferSize(1024, 2048);
- Ice::IPConnectionInfoPtr info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connection->getInfo());
+ Ice::TCPConnectionInfoPtr info = getTCPConnectionInfo(connection->getInfo());
test(info);
test(!info->incoming);
test(info->adapterName.empty());
@@ -188,16 +223,13 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
Ice::HeaderDict headers;
- Ice::WSConnectionInfoPtr wsinfo = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, info);
- if(wsinfo)
- {
- headers = wsinfo->headers;
- }
+ Ice::WSConnectionInfoPtr wsinfo = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, connection->getInfo());
+ test(wsinfo);
+ headers = wsinfo->headers;
- IceSSL::WSSConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::WSSConnectionInfo, info);
- if(wssinfo)
+ if(base->ice_getConnection()->type() == "wss")
{
- headers = wssinfo->headers;
+ IceSSL::ConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::ConnectionInfo, wsinfo->underlying);
test(wssinfo->verified);
#if !defined(ICE_OS_WINRT) && TARGET_OS_IPHONE==0
test(!wssinfo->certs.empty());
@@ -219,20 +251,20 @@ allTests(const Ice::CommunicatorPtr& communicator)
connection = base->ice_datagram()->ice_getConnection();
connection->setBufferSize(2048, 1024);
- info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connection->getInfo());
- test(!info->incoming);
- test(info->adapterName.empty());
- test(info->localPort > 0);
- test(info->remotePort == 12010);
+ Ice::UDPConnectionInfoPtr udpinfo = ICE_DYNAMIC_CAST(Ice::UDPConnectionInfo, connection->getInfo());
+ test(!udpinfo->incoming);
+ test(udpinfo->adapterName.empty());
+ test(udpinfo->localPort > 0);
+ test(udpinfo->remotePort == 12010);
if(defaultHost == "127.0.0.1")
{
- test(info->remoteAddress == defaultHost);
- test(info->localAddress == defaultHost);
+ test(udpinfo->remoteAddress == defaultHost);
+ test(udpinfo->localAddress == defaultHost);
}
#if !defined(ICE_OS_WINRT)
- test(info->rcvSize >= 2048);
- test(info->sndSize >= 1024);
+ test(udpinfo->rcvSize >= 2048);
+ test(udpinfo->sndSize >= 1024);
#endif
}
cout << "ok" << endl;
diff --git a/cpp/test/Ice/info/TestI.cpp b/cpp/test/Ice/info/TestI.cpp
index ddacb9874dc..06e17ab89a1 100644
--- a/cpp/test/Ice/info/TestI.cpp
+++ b/cpp/test/Ice/info/TestI.cpp
@@ -16,6 +16,39 @@ using namespace std;
using namespace Ice;
using namespace Test;
+namespace
+{
+
+Ice::IPEndpointInfoPtr
+getIPEndpointInfo(const Ice::EndpointInfoPtr& info)
+{
+ for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPEndpointInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+Ice::IPConnectionInfoPtr
+getIPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPConnectionInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
void
TestI::shutdown(const Ice::Current& current)
{
@@ -38,8 +71,8 @@ TestI::getEndpointInfoAsContext(const Ice::Current& c)
os << info->type();
ctx["type"] = os.str();
- Ice::IPEndpointInfoPtr ipinfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, info);
- test(info);
+ Ice::IPEndpointInfoPtr ipinfo = getIPEndpointInfo(info);
+ test(ipinfo);
ctx["host"] = ipinfo->host;
os.str("");
os << ipinfo->port;
@@ -64,7 +97,7 @@ TestI::getConnectionInfoAsContext(const Ice::Current& c)
ctx["incoming"] = info->incoming ? "true" : "false";
ostringstream os;
- Ice::IPConnectionInfoPtr ipinfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, info);
+ Ice::IPConnectionInfoPtr ipinfo = getIPConnectionInfo(info);
test(ipinfo);
ctx["localAddress"] = ipinfo->localAddress;
os.str("");
@@ -84,14 +117,5 @@ TestI::getConnectionInfoAsContext(const Ice::Current& c)
}
}
- IceSSL::WSSConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::WSSConnectionInfo, info);
- if(wssinfo)
- {
- for(Ice::HeaderDict::const_iterator p = wssinfo->headers.begin(); p != wssinfo->headers.end(); ++p)
- {
- ctx["ws." + p->first] = p->second;
- }
- }
-
return ctx;
}
diff --git a/cpp/test/Ice/metrics/AllTests.cpp b/cpp/test/Ice/metrics/AllTests.cpp
index 08e6ba8e8af..86fba324ef5 100644
--- a/cpp/test/Ice/metrics/AllTests.cpp
+++ b/cpp/test/Ice/metrics/AllTests.cpp
@@ -494,6 +494,24 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
map<string, IceMX::MetricsPtr> map;
+ string endpoint;
+ {
+ ostringstream os;
+ os << communicator->getProperties()->getPropertyWithDefault("Ice.Default.Protocol", "tcp") << " -h 127.0.0.1 -p 12010";
+ endpoint = os.str();
+ }
+ string type;
+ string isSecure;
+ if(!collocated)
+ {
+ Ice::EndpointInfoPtr endpointInfo = metrics->ice_getConnection()->getEndpoint()->getInfo();
+ {
+ ostringstream os;
+ os << endpointInfo->type();
+ type = os.str();
+ }
+ isSecure = endpointInfo->secure() ? "true": "false";
+ }
if(!collocated)
{
cout << "testing connection metrics... " << flush;
@@ -567,7 +585,8 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
updateProps(clientProps, serverProps, update.get(), props, "Connection");
map = toMap(serverMetrics->getMetricsView("View", timestamp)["Connection"]);
-
+ test(map["active"]->current == 1);
+ map = toMap(clientMetrics->getMetricsView("View", timestamp)["Connection"]);
test(map["active"]->current == 1);
ControllerPrxPtr controller = ICE_CHECKED_CAST(ControllerPrx, communicator->stringToProxy("controller:default -p 12011"));
@@ -631,11 +650,10 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "parent", "Communicator");
//testAttribute(clientMetrics, clientProps, update.get(), "Connection", "id", "");
- testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpoint", "tcp -h 127.0.0.1 -p 12010 -t 500");
-
- testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointType", "1");
+ testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpoint", endpoint + " -t 500");
+ testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointType", type);
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointIsDatagram", "false");
- testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointIsSecure", "false");
+ testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointIsSecure", isSecure);
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointTimeout", "500");
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointCompress", "false");
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointHost", "127.0.0.1");
@@ -695,11 +713,11 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "parent", "Communicator", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "id", "127.0.0.1:12010", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 60000", c);
+ endpoint + " -t 60000", c);
- testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointType", "1", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointType", type, c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointIsDatagram", "false", c);
- testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointIsSecure", "false", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointIsSecure", isSecure, c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointTimeout", "60000", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointCompress", "false", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointHost", "127.0.0.1", c);
@@ -724,7 +742,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].size() == 1);
m1 = clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"][0];
- test(m1->current <= 1 && m1->total == 1 && m1->id == "tcp -h localhost -p 12010 -t infinite");
+ test(m1->current <= 1 && m1->total == 1 && m1->id == prx->ice_getConnection()->getEndpoint()->toString());
prx->ice_getConnection()->close(false);
@@ -755,13 +773,13 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "parent", "Communicator", c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "id",
- "tcp -h localhost -p 12010 -t infinite", c);
+ prx->ice_getConnection()->getEndpoint()->toString(), c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpoint",
- "tcp -h localhost -p 12010 -t infinite", c);
+ prx->ice_getConnection()->getEndpoint()->toString(), c);
- testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointType", "1", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointType", type, c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointIsDatagram", "false", c);
- testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointIsSecure", "false", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointIsSecure", isSecure, c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointTimeout", "-1", c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointCompress", "false", c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointHost", "localhost", c);
@@ -861,13 +879,12 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "id", "metrics [op]", op);
if(!collocated)
{
- testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpoint", "tcp -h 127.0.0.1 -p 12010 -t 60000",
- op);
+ testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpoint", endpoint + " -t 60000", op);
//testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "connection", "", op);
- testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointType", "1", op);
+ testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointType", type, op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointIsDatagram", "false", op);
- testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointIsSecure", "false", op);
+ testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointIsSecure", isSecure, op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointTimeout", "60000", op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointCompress", "false", op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointHost", "127.0.0.1", op);
@@ -1275,8 +1292,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "encoding", "1.1", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "mode", "twoway", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "proxy",
- "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 60000", op);
-
+ "metrics -t -e 1.1:" + endpoint + " -t 60000", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "context.entry1", "test", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "context.entry2", "", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "context.entry3", "", op);
diff --git a/cpp/test/Ice/metrics/Client.cpp b/cpp/test/Ice/metrics/Client.cpp
index 88c19ae6f18..65611a7de95 100644
--- a/cpp/test/Ice/metrics/Client.cpp
+++ b/cpp/test/Ice/metrics/Client.cpp
@@ -36,7 +36,7 @@ main(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
- initData.properties->setProperty("Ice.Admin.Endpoints", "tcp");
+ initData.properties->setProperty("Ice.Admin.Endpoints", "default");
initData.properties->setProperty("Ice.Admin.InstanceName", "client");
initData.properties->setProperty("Ice.Admin.DelayCreation", "1");
initData.properties->setProperty("Ice.Warn.Connections", "0");
diff --git a/cpp/test/Ice/networkProxy/AllTests.cpp b/cpp/test/Ice/networkProxy/AllTests.cpp
index 3ab6aedcffd..f1d2fa1fe71 100644
--- a/cpp/test/Ice/networkProxy/AllTests.cpp
+++ b/cpp/test/Ice/networkProxy/AllTests.cpp
@@ -14,6 +14,25 @@
using namespace std;
using namespace Test;
+namespace
+{
+
+Ice::IPConnectionInfoPtr
+getIPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPConnectionInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
void
allTests(const Ice::CommunicatorPtr& communicator)
{
@@ -32,7 +51,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing connection information... " << flush;
{
- Ice::IPConnectionInfoPtr info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, test->ice_getConnection()->getInfo());
+ Ice::IPConnectionInfoPtr info = getIPConnectionInfo(test->ice_getConnection()->getInfo());
test(info->remotePort == 12030 || info->remotePort == 12031); // make sure we are connected to the proxy port.
}
cout << "ok" << endl;
diff --git a/cpp/test/Ice/operations/Client.cpp b/cpp/test/Ice/operations/Client.cpp
index 73b19851fb0..a000b049a77 100644
--- a/cpp/test/Ice/operations/Client.cpp
+++ b/cpp/test/Ice/operations/Client.cpp
@@ -17,7 +17,7 @@ using namespace std;
int
run(int, char**, const Ice::CommunicatorPtr& communicator, bool remote)
-{
+{
Test::MyClassPrxPtr allTests(const Ice::CommunicatorPtr&);
Test::MyClassPrxPtr myClass = allTests(communicator);
@@ -67,8 +67,7 @@ main(int argc, char* argv[])
initData.properties = Ice::createProperties(argc, argv);
initData.properties->setProperty("Ice.ThreadPool.Client.Size", "2");
initData.properties->setProperty("Ice.ThreadPool.Client.SizeWarn", "0");
-
- initData.properties->setProperty("Ice.BatchAutoFlushSize", "100");
+ initData.properties->setProperty("Ice.BatchAutoFlushSize", "100");
Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
RemoteConfig rc("Ice/operations", argc, argv, ich.communicator());
diff --git a/cpp/test/Ice/slicing/exceptions/AllTests.cpp b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
index 28e11dae7b4..b510a7f0c76 100644
--- a/cpp/test/Ice/slicing/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
@@ -411,7 +411,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
test(false);
}
-
+
#else
CallbackPtr cb = new Callback;
test->begin_baseAsBase(
@@ -557,7 +557,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownDerivedAsKnownDerived(
- newCallback_TestIntf_knownDerivedAsKnownDerived(cb, &Callback::response,
+ newCallback_TestIntf_knownDerivedAsKnownDerived(cb, &Callback::response,
&Callback::exception_knownDerivedAsKnownDerived));
cb->check();
#endif
@@ -604,7 +604,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownIntermediateAsBase(
- newCallback_TestIntf_unknownIntermediateAsBase(cb, &Callback::response,
+ newCallback_TestIntf_unknownIntermediateAsBase(cb, &Callback::response,
&Callback::exception_unknownIntermediateAsBase));
cb->check();
#endif
@@ -653,7 +653,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownIntermediateAsBase(
- newCallback_TestIntf_knownIntermediateAsBase(cb, &Callback::response,
+ newCallback_TestIntf_knownIntermediateAsBase(cb, &Callback::response,
&Callback::exception_knownIntermediateAsBase));
cb->check();
#endif
@@ -704,7 +704,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownMostDerivedAsBase(
- newCallback_TestIntf_knownMostDerivedAsBase(cb, &Callback::response,
+ newCallback_TestIntf_knownMostDerivedAsBase(cb, &Callback::response,
&Callback::exception_knownMostDerivedAsBase));
cb->check();
#endif
@@ -753,7 +753,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownIntermediateAsKnownIntermediate(
- newCallback_TestIntf_knownIntermediateAsKnownIntermediate(cb, &Callback::response,
+ newCallback_TestIntf_knownIntermediateAsKnownIntermediate(cb, &Callback::response,
&Callback::exception_knownIntermediateAsKnownIntermediate));
cb->check();
#endif
@@ -804,7 +804,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownMostDerivedAsKnownIntermediate(
- newCallback_TestIntf_knownMostDerivedAsKnownIntermediate(cb, &Callback::response,
+ newCallback_TestIntf_knownMostDerivedAsKnownIntermediate(cb, &Callback::response,
&Callback::exception_knownMostDerivedAsKnownIntermediate));
cb->check();
#endif
@@ -855,7 +855,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownMostDerivedAsKnownMostDerived(
- newCallback_TestIntf_knownMostDerivedAsKnownMostDerived(cb, &Callback::response,
+ newCallback_TestIntf_knownMostDerivedAsKnownMostDerived(cb, &Callback::response,
&Callback::exception_knownMostDerivedAsKnownMostDerived));
cb->check();
#endif
@@ -904,7 +904,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownMostDerived1AsBase(
- newCallback_TestIntf_unknownMostDerived1AsBase(cb, &Callback::response,
+ newCallback_TestIntf_unknownMostDerived1AsBase(cb, &Callback::response,
&Callback::exception_unknownMostDerived1AsBase));
cb->check();
#endif
@@ -953,7 +953,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownMostDerived1AsKnownIntermediate(
- newCallback_TestIntf_unknownMostDerived1AsKnownIntermediate(cb, &Callback::response,
+ newCallback_TestIntf_unknownMostDerived1AsKnownIntermediate(cb, &Callback::response,
&Callback::exception_unknownMostDerived1AsKnownIntermediate));
cb->check();
#endif
@@ -1000,7 +1000,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownMostDerived2AsBase(
- newCallback_TestIntf_unknownMostDerived2AsBase(cb, &Callback::response,
+ newCallback_TestIntf_unknownMostDerived2AsBase(cb, &Callback::response,
&Callback::exception_unknownMostDerived2AsBase));
cb->check();
#endif
@@ -1072,11 +1072,6 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::OperationNotExistException&)
{
}
- catch(const Ice::LocalException& ex)
- {
- cout << endl << "** OOPS" << endl << ex << endl;
- test(false);
- }
catch(...)
{
test(false);
diff --git a/cpp/test/IceSSL/configuration/AllTests.cpp b/cpp/test/IceSSL/configuration/AllTests.cpp
index 3313424859a..65d4d031640 100644
--- a/cpp/test/IceSSL/configuration/AllTests.cpp
+++ b/cpp/test/IceSSL/configuration/AllTests.cpp
@@ -2,7 +2,7 @@
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
-// This copy of Ice is licensed to you under the terms described in the
+// This copy of Ice is licensed to you under the terms dribed in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
@@ -15,6 +15,9 @@
#ifdef __APPLE__
# include <sys/sysctl.h>
+#if TARGET_OS_IPHONE != 0
+#include <IceSSL/Util.h> // For loadCertificateChain
+#endif
#endif
#ifdef ICE_CPP11_MAPPING
@@ -141,6 +144,83 @@ private:
vector<PCCERT_CONTEXT> _certs;
};
+#elif defined(__APPLE__) && TARGET_OS_IPHONE != 0
+class ImportCerts
+{
+public:
+
+ ImportCerts(const string& defaultDir, const char* certificates[])
+ {
+ for(int i = 0; certificates[i] != 0; ++i)
+ {
+ string resolved;
+ if(IceSSL::checkPath(certificates[i], defaultDir, false, resolved))
+ {
+ CFArrayRef certs = IceSSL::loadCertificateChain(resolved, "", "", "", "password", 0, 0);
+ SecIdentityRef identity = (SecIdentityRef)CFArrayGetValueAtIndex(certs, 0);
+ CFRetain(identity);
+ _identities.push_back(identity);
+ OSStatus err;
+ CFMutableDictionaryRef query;
+
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecValueRef, identity);
+ if((err = SecItemAdd(query, 0)))
+ {
+ cerr << "failed to add identity " << certificates[i] << ": " << err << endl;
+ }
+ CFRelease(query);
+
+ // query = CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ // CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
+ // CFDictionarySetValue(query, kSecReturnRef, kCFBooleanTrue);
+ // CFDictionarySetValue(query, kSecMatchLimit, kSecMatchLimitAll);
+ // CFArrayRef array = 0;
+ // err = SecItemCopyMatching(query, (CFTypeRef*)&array);
+ // printf("Certificates\n");
+ // for(int i = 0; i < CFArrayGetCount(array); ++i)
+ // {
+ // printf("Cert %d: %s\n", i, (new IceSSL::Certificate((SecCertificateRef)CFArrayGetValueAtIndex(array, i)))->toString().c_str());
+ // }
+ // CFRelease(certs);
+ }
+ }
+ // Nothing to do.
+ }
+
+ ~ImportCerts()
+ {
+ cleanup();
+ }
+
+ void cleanup()
+ {
+ CFMutableDictionaryRef query;
+ for(vector<SecIdentityRef>::const_iterator p = _identities.begin(); p != _identities.end(); ++p)
+ {
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecClass, kSecClassIdentity);
+ CFDictionarySetValue(query, kSecValueRef, *p);
+ SecItemDelete(query);
+ CFRelease(query);
+
+ SecCertificateRef cert;
+ SecIdentityCopyCertificate(*p, &cert);
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
+ CFDictionarySetValue(query, kSecValueRef, cert);
+ SecItemDelete(query);
+ CFRelease(query);
+
+ CFRelease(*p);
+ }
+ _identities.clear();
+ }
+
+private:
+
+ vector<SecIdentityRef> _identities;
+};
#else
class ImportCerts
{
@@ -197,6 +277,7 @@ public:
{
if(info->nativeCerts.size() > 0)
{
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
//
// Subject alternative name
//
@@ -243,6 +324,7 @@ public:
test(find(ipAddresses.begin(), ipAddresses.end(), "127.0.0.1") != ipAddresses.end());
test(find(emailAddresses.begin(), emailAddresses.end(), "issuer@zeroc.com") != emailAddresses.end());
}
+#endif
}
_hadCert = info->nativeCerts.size() != 0;
@@ -306,7 +388,8 @@ createClientProps(const Ice::PropertiesPtr& defaultProps, const string& defaultD
{
result->setProperty("IceSSL.Password", "password");
}
- //result->setProperty("IceSSL.Trace.Security", "1");
+// result->setProperty("IceSSL.Trace.Security", "1");
+// result->setProperty("Ice.Trace.Network", "1");
#ifdef ICE_USE_SECURE_TRANSPORT
ostringstream keychainName;
keychainName << "../certs/keychain/client" << keychainN++ << ".keychain";
@@ -338,7 +421,8 @@ createServerProps(const Ice::PropertiesPtr& defaultProps, const string& defaultD
{
result["IceSSL.Password"] = "password";
}
- //result["IceSSL.Trace.Security"] = "1";
+// result["Ice.Trace.Network"] = "1";
+// result["IceSSL.Trace.Security"] = "1";
#ifdef ICE_USE_SECURE_TRANSPORT
ostringstream keychainName;
keychainName << "../certs/keychain/server" << keychainN << ".keychain";
@@ -420,8 +504,8 @@ void verify(const IceSSL::CertificatePtr& cert, const IceSSL::CertificatePtr& ca
cerr << endl;
}
-void
-allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, bool shutdown)
+Test::ServerFactoryPrxPtr
+allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12)
{
bool elCapitanUpdate2OrLower = false;
#ifdef __APPLE__
@@ -441,14 +525,19 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
}
}
#endif
-
- string factoryRef = "factory:tcp -p 12010";
+ string endpt = getTestEndpoint(communicator, 0);
+ string factoryRef = "factory:" + endpt;
ObjectPrxPtr base = communicator->stringToProxy(factoryRef);
test(base);
Test::ServerFactoryPrxPtr factory = ICE_CHECKED_CAST(Test::ServerFactoryPrx, base);
string defaultHost = communicator->getProperties()->getProperty("Ice.Default.Host");
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
string defaultDir = testDir + "/../certs";
+#else
+ string defaultDir = "certs";
+#endif
+
Ice::PropertiesPtr defaultProps = communicator->getProperties();
#ifdef _WIN32
string sep = ";";
@@ -484,7 +573,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
//
// Anonymous cipher are not supported with SChannel
//
-#ifndef ICE_USE_SCHANNEL
+#if !defined(ICE_USE_SCHANNEL)
{
InitializationData initData;
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12);
@@ -647,16 +736,22 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
IceSSL::CertificatePtr serverCert = IceSSL::Certificate::load(defaultDir + "/s_rsa_ca1_pub.pem");
test(ICE_TARGET_EQUALS(IceSSL::Certificate::decode(serverCert->encode()), serverCert));
test(ICE_TARGET_EQUALS(serverCert, serverCert));
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
test(serverCert->checkValidity());
test(!serverCert->checkValidity(IceUtil::Time::seconds(0)));
+#endif
IceSSL::CertificatePtr caCert = IceSSL::Certificate::load(defaultDir + "/cacert1.pem");
+ IceSSL::CertificatePtr caCert2 = IceSSL::Certificate::load(defaultDir + "/cacert2.pem");
test(ICE_TARGET_EQUALS(caCert, caCert));
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
test(caCert->checkValidity());
test(!caCert->checkValidity(IceUtil::Time::seconds(0)));
+#endif
test(!serverCert->verify(serverCert));
test(serverCert->verify(caCert));
+ test(!serverCert->verify(caCert2));
test(caCert->verify(caCert));
info = ICE_DYNAMIC_CAST(IceSSL::NativeConnectionInfo, server->ice_getConnection()->getInfo());
@@ -669,9 +764,11 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
test(!(ICE_TARGET_EQUALS(serverCert, info->nativeCerts[1])));
test(!(ICE_TARGET_EQUALS(caCert, info->nativeCerts[0])));
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
test(info->nativeCerts[0]->checkValidity() && info->nativeCerts[1]->checkValidity());
test(!info->nativeCerts[0]->checkValidity(IceUtil::Time::seconds(0)) &&
!info->nativeCerts[1]->checkValidity(IceUtil::Time::seconds(0)));
+#endif
test(info->nativeCerts[0]->verify(info->nativeCerts[1]));
test(info->nativeCerts.size() == 2 &&
info->nativeCerts[0]->getSubjectDN() == serverCert->getSubjectDN() &&
@@ -874,8 +971,9 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
{
server->ice_ping();
}
- catch(const LocalException&)
+ catch(const LocalException& ex)
{
+ cerr << ex << endl;
test(false);
}
fact->destroyServer(server);
@@ -1589,10 +1687,12 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
//
// This should fail because the server's certificate is expired.
//
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
{
IceSSL::CertificatePtr cert = IceSSL::Certificate::load(defaultDir + "/s_rsa_ca1_exp_pub.pem");
test(!cert->checkValidity());
}
+#endif
InitializationData initData;
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12, "c_rsa_ca1", "cacert1");
@@ -1621,10 +1721,12 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
//
// This should fail because the client's certificate is expired.
//
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
{
IceSSL::CertificatePtr cert = IceSSL::Certificate::load(defaultDir + "/c_rsa_ca1_exp_pub.pem");
test(!cert->checkValidity());
}
+#endif
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12, "c_rsa_ca1_exp", "cacert1");
comm = initialize(initData);
@@ -2193,9 +2295,14 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
cout << "ok" << endl;
cout << "testing IceSSL.TrustOnly... " << flush;
+ //
+ // iOS support only provides access to the CN of the certificate so we
+ // can't check for other attributes
+ //
{
InitializationData initData;
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12, "c_rsa_ca1", "cacert1");
+ initData.properties->setProperty("IceSSL.TrustOnly", "CN=Server");
initData.properties->setProperty("IceSSL.TrustOnly", "C=US, ST=Florida, O=ZeroC\\, Inc.,"
"OU=Ice, emailAddress=info@zeroc.com, CN=Server");
CommunicatorPtr comm = initialize(initData);
@@ -2568,7 +2675,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
test(fact);
Test::Properties d = createServerProps(defaultProps, defaultDir, defaultHost, p12, "s_rsa_ca1", "cacert1");
d["IceSSL.VerifyPeer"] = "0";
- d["IceSSL.TrustOnly"] = "C=US, ST=Florida, O=ZeroC\\, Inc.,OU=Ice, emailAddress=info@zeroc.com, CN=Client";
+ d["IceSSL.TrustOnly"] = "CN=Client";
Test::ServerPrxPtr server = fact->createServer(d);
try
{
@@ -2593,7 +2700,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
Test::ServerFactoryPrxPtr fact = ICE_CHECKED_CAST(Test::ServerFactoryPrx, comm->stringToProxy(factoryRef));
test(fact);
Test::Properties d = createServerProps(defaultProps, defaultDir, defaultHost, p12, "s_rsa_ca1", "cacert1");
- d["IceSSL.TrustOnly"] = "!C=US, ST=Florida, O=ZeroC\\, Inc.,OU=Ice, emailAddress=info@zeroc.com, CN=Client";
+ d["IceSSL.TrustOnly"] = "!CN=Client";
d["IceSSL.VerifyPeer"] = "0";
Test::ServerPrxPtr server = fact->createServer(d);
try
@@ -3116,7 +3223,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
cout << "testing IceSSL.FindCert... " << flush;
const char* clientFindCertProperties[] =
{
- "SUBJECT:Client",
+// "SUBJECT:Client",
"LABEL:'Client'",
"SUBJECTKEYID:'FC 5D 4F AB F0 6C 03 11 B8 F3 68 CF 89 54 92 3F F9 79 2A 06'",
"SERIAL:02",
@@ -3126,7 +3233,10 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
const char* serverFindCertProperties[] =
{
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
+ // iOS match on Subject DN isn't supported by SecItemCopyMatch
"SUBJECT:Server",
+#endif
"LABEL:'Server'",
"SUBJECTKEYID:'47 84 AE F9 F2 85 3D 99 30 6A 03 38 41 1A B9 EB C3 9C B5 4D'",
"SERIAL:01",
@@ -3139,7 +3249,10 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
"nolabel",
"unknownlabel:foo",
"LABEL:",
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
+ // iOS match on Subject DN isn't supported by SecItemCopyMatch
"SUBJECT:ServerX",
+#endif
"LABEL:'ServerX'",
"SUBJECTKEYID:'a6 42 aa 17 04 41 86 56 67 e4 04 64 59 34 30 c7 4c 6b ef ff'",
"SERIAL:04",
@@ -3147,6 +3260,9 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
0
};
+ const char* certificates[] = {"/s_rsa_ca1.p12", "/c_rsa_ca1.p12", 0};
+ ImportCerts import(defaultDir, certificates);
+
for(int i = 0; clientFindCertProperties[i] != 0; i++)
{
InitializationData initData;
@@ -3169,6 +3285,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
d["IceSSL.Keychain"] = "../certs/Find.keychain";
d["IceSSL.KeychainPassword"] = "password";
d["IceSSL.FindCert"] = serverFindCertProperties[i];
+
//
// Use TrustOnly to ensure the peer has pick the expected certificate.
//
@@ -3198,6 +3315,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
try
{
CommunicatorPtr comm = initialize(initData);
+ printf("failed %s", failFindCertProperties[i]);
test(false);
}
catch(const PluginInitializationException&)
@@ -3247,11 +3365,11 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
comm = initialize(initData);
p = comm->stringToProxy("dummy:wss -h demo.zeroc.com -p 5064");
- IceSSL::WSSConnectionInfoPtr info;
try
{
- info = ICE_DYNAMIC_CAST(IceSSL::WSSConnectionInfo, p->ice_getConnection()->getInfo());
- test(info->verified);
+ Ice::WSConnectionInfoPtr info = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, p->ice_getConnection()->getInfo());
+ IceSSL::ConnectionInfoPtr sslInfo = ICE_DYNAMIC_CAST(IceSSL::ConnectionInfo, info->underlying);
+ test(sslInfo->verified);
}
catch(const Ice::LocalException& ex)
{
@@ -3261,9 +3379,5 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
}
cout << "ok" << endl;
#endif
-
- if(shutdown)
- {
- factory->shutdown();
- }
+ return factory;
}
diff --git a/cpp/test/IceSSL/configuration/Client.cpp b/cpp/test/IceSSL/configuration/Client.cpp
index 14538e7beac..68d3ad936e1 100644
--- a/cpp/test/IceSSL/configuration/Client.cpp
+++ b/cpp/test/IceSSL/configuration/Client.cpp
@@ -9,26 +9,51 @@
#include <Ice/Ice.h>
#include <IceSSL/IceSSL.h>
+#include <TestCommon.h>
+#include <Test.h>
+
+DEFINE_TEST("client")
using namespace std;
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
+ string testdir;
+#if TARGET_OS_IPHONE == 0
if(argc < 2)
{
cerr << "Usage: " << argv[0] << " testdir" << endl;
return 1;
}
+ testdir = argv[1];
+#endif
- void allTests(const Ice::CommunicatorPtr&, const string&, bool, bool);
-
- cerr << "testing with PKCS12 certificates..." << endl;
- allTests(communicator, argv[1], true, false);
- cerr << "testing with PEM certificates..." << endl;
- allTests(communicator, argv[1], false, true);
+ Test::ServerFactoryPrxPtr allTests(const Ice::CommunicatorPtr&, const string&, bool);
+ try
+ {
+ cerr << "testing with PKCS12 certificates..." << endl;
+ Test::ServerFactoryPrxPtr factory = allTests(communicator, testdir, true);
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
+ cerr << "testing with PEM certificates..." << endl;
+ factory = allTests(communicator, testdir, false);
+#endif
+ if(factory)
+ {
+ factory->shutdown();
+ }
+ }
+ catch(const IceSSL::CertificateReadException& ex)
+ {
+ cout << "couldn't read certificate: " << ex.reason << endl;
+ }
+ catch(const std::exception& ex)
+ {
+ cout << "unexpected exception: " << ex.what() << endl;
+ }
return EXIT_SUCCESS;
+
}
int
diff --git a/cpp/test/IceSSL/configuration/Makefile.mk b/cpp/test/IceSSL/configuration/Makefile.mk
index 92098e429b6..9eb4e1b4c75 100644
--- a/cpp/test/IceSSL/configuration/Makefile.mk
+++ b/cpp/test/IceSSL/configuration/Makefile.mk
@@ -9,4 +9,8 @@
$(test)_dependencies = IceSSL Ice TestCommon
+# Need to load certificates with functions from src/IceSSL/Util.h
+$(test)[iphoneos]_cppflags := -Isrc
+$(test)[iphonesimulator]_cppflags := -Isrc
+
tests += $(test)
diff --git a/cpp/test/IceSSL/configuration/Server.cpp b/cpp/test/IceSSL/configuration/Server.cpp
index 5ed1e401b15..6a1f98614dd 100644
--- a/cpp/test/IceSSL/configuration/Server.cpp
+++ b/cpp/test/IceSSL/configuration/Server.cpp
@@ -9,18 +9,21 @@
#include <Ice/Ice.h>
#include <TestI.h>
+#include <TestCommon.h>
+
+DEFINE_TEST("server")
using namespace std;
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
- communicator->getProperties()->setProperty("TestAdapter.Endpoints", "tcp -p 12010");
+ communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::Identity id = communicator->stringToIdentity("factory");
adapter->add(ICE_MAKE_SHARED(ServerFactoryI), id);
adapter->activate();
-
+ TEST_READY
communicator->waitForShutdown();
return EXIT_SUCCESS;
}
diff --git a/cpp/test/IceSSL/configuration/TestI.cpp b/cpp/test/IceSSL/configuration/TestI.cpp
index 7723da865b3..39b78d02712 100644
--- a/cpp/test/IceSSL/configuration/TestI.cpp
+++ b/cpp/test/IceSSL/configuration/TestI.cpp
@@ -45,7 +45,8 @@ ServerI::checkCert(ICE_IN(string) subjectDN, ICE_IN(string) issuerDN, const Ice:
test(info->verified);
test(info->nativeCerts.size() == 2 &&
info->nativeCerts[0]->getSubjectDN() == IceSSL::DistinguishedName(subjectDN) &&
- info->nativeCerts[0]->getIssuerDN() == IceSSL::DistinguishedName(issuerDN));
+ info->nativeCerts[0]->getIssuerDN() == IceSSL::DistinguishedName(issuerDN)
+ );
}
catch(const Ice::LocalException&)
{
diff --git a/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj b/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj
index 497f4f097c9..f254b1f0bef 100755
--- a/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj
+++ b/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj
@@ -66,6 +66,9 @@
144B483C1A78F71F00C0E06B /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 344126370FD8E8EA00C8D69C /* CFNetwork.framework */; };
144B483D1A78F71F00C0E06B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34E396620FF1D71400FBACD6 /* CoreGraphics.framework */; };
1450A10C1ABC5E9C00A71895 /* client.p12 in Resources */ = {isa = PBXBuildFile; fileRef = 1450A10B1ABC5E9C00A71895 /* client.p12 */; };
+ 14D7F3391D0ED442008C79C9 /* certs in Resources */ = {isa = PBXBuildFile; fileRef = 14D7F3381D0ED442008C79C9 /* certs */; };
+ 14D7F33A1D0ED442008C79C9 /* certs in Resources */ = {isa = PBXBuildFile; fileRef = 14D7F3381D0ED442008C79C9 /* certs */; };
+ 14D7F33B1D0ED442008C79C9 /* certs in Resources */ = {isa = PBXBuildFile; fileRef = 14D7F3381D0ED442008C79C9 /* certs */; };
D837179F1BFFC25C005D65BC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8842ED91BFF87E700A8B607 /* Images.xcassets */; };
D8842EDA1BFF87E700A8B607 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8842ED91BFF87E700A8B607 /* Images.xcassets */; };
D8842EDC1BFF885600A8B607 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D8842EDB1BFF885600A8B607 /* Default-568h@2x.png */; };
@@ -79,6 +82,7 @@
1450A10B1ABC5E9C00A71895 /* client.p12 */ = {isa = PBXFileReference; lastKnownFileType = file; name = client.p12; path = ../../../../ice/certs/client.p12; sourceTree = "<group>"; };
1477FACD1A652B7E00BC2890 /* C++98 Test Suite-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "C++98 Test Suite-Info.plist"; sourceTree = "<group>"; };
148668D31B6BAFD300234C12 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
+ 14D7F3381D0ED442008C79C9 /* certs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = certs; path = ../IceSSL/certs; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
@@ -198,6 +202,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ 14D7F3381D0ED442008C79C9 /* certs */,
342EBA8A0E926F90000051FA /* cacert.der */,
1450A10B1ABC5E9C00A71895 /* client.p12 */,
D8842EDB1BFF885600A8B607 /* Default-568h@2x.png */,
@@ -328,6 +333,7 @@
14103B141CFC5E0E0097DE5A /* Default-568h@2x.png in Resources */,
14103B151CFC5E0E0097DE5A /* client.p12 in Resources */,
14103B161CFC5E0E0097DE5A /* cacert.der in Resources */,
+ 14D7F33B1D0ED442008C79C9 /* certs in Resources */,
14103B171CFC5E0E0097DE5A /* TestSelect-iPad.xib in Resources */,
14103B181CFC5E0E0097DE5A /* MainWindow-iPad.xib in Resources */,
14103B191CFC5E0E0097DE5A /* TestView.xib in Resources */,
@@ -339,6 +345,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 14D7F33A1D0ED442008C79C9 /* certs in Resources */,
142B83841B6BA7A600E28347 /* MainWindow.xib in Resources */,
D837179F1BFFC25C005D65BC /* Images.xcassets in Resources */,
142B83851B6BA7A600E28347 /* TestSelect.xib in Resources */,
@@ -363,6 +370,7 @@
D8842EDC1BFF885600A8B607 /* Default-568h@2x.png in Resources */,
1450A10C1ABC5E9C00A71895 /* client.p12 in Resources */,
144B482B1A78F71F00C0E06B /* cacert.der in Resources */,
+ 14D7F3391D0ED442008C79C9 /* certs in Resources */,
144B482C1A78F71F00C0E06B /* TestSelect-iPad.xib in Resources */,
144B482D1A78F71F00C0E06B /* MainWindow-iPad.xib in Resources */,
144B482E1A78F71F00C0E06B /* TestView.xib in Resources */,
@@ -399,7 +407,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "#\n# We don't use a CopyFile build phase here to copy the test bundles because the test\n# bundles are located in different location depending on the platform. This script\n# copies the bundles if updated and sign them.\n#\nFRAMEWORKS_PATH=\"${TARGET_BUILD_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\ncd \"Bundles-${PLATFORM_NAME}\"\nif [ ! -d \"$FRAMEWORKS_PATH\" ]; then\n mkdir -p \"$FRAMEWORKS_PATH\"\nfi;\nfor i in `ls -d *.bundle`;\ndo\n if [ ! -d \"$FRAMEWORKS_PATH/$i\" -o \"$i\" -nt \"$FRAMEWORKS_PATH/$i\" ];\n then\n echo \"Copying $i\";\n cp -rf $i \"$FRAMEWORKS_PATH\"/;\n fi;\ndone\n\n";
+ shellScript = "#\n# We don't use a CopyFile build phase here to copy the test bundles because the test\n# bundles are located in different location depending on the platform. This script\n# copies the bundles if updated and sign them.\n#\nFRAMEWORKS_PATH=\"${TARGET_BUILD_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\ncd \"Bundles-${PLATFORM_NAME}\"\nif [ ! -d \"$FRAMEWORKS_PATH\" ]; then\n mkdir -p \"$FRAMEWORKS_PATH\"\nfi;\nfor i in `ls -d */*.bundle`;\ndo\n if [ ! -d \"$FRAMEWORKS_PATH/$i\" -o \"$i\" -nt \"$FRAMEWORKS_PATH/$i\" ];\n then\n echo \"Copying $i\";\n mkdir -p \"$FRAMEWORKS_PATH/$(dirname $i)\"\n cp -rf $i \"$FRAMEWORKS_PATH/$(dirname $i)\"\n fi;\ndone\n\n";
};
144B488F1A78F71F00C0E06B /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
diff --git a/cpp/test/ios/Classes/AppDelegate.mm b/cpp/test/ios/Classes/AppDelegate.mm
index 6f8f217bc4a..ac7e99dcaeb 100644
--- a/cpp/test/ios/Classes/AppDelegate.mm
+++ b/cpp/test/ios/Classes/AppDelegate.mm
@@ -65,6 +65,7 @@ static const struct TestData alltests[] =
{ @"metrics", @"Ice_metrics", @"client.bundle", @"server.bundle", 0, 0, false, false, false, false, true },
{ @"enums", @"Ice_enums", @"client.bundle", @"server.bundle", 0, 0, true, true, false, true, true },
{ @"services", @"Ice_services", @"client.bundle", 0, 0, 0, true, true, false, false, true },
+{ @"configuration", @"IceSSL_configuration", @"client.bundle", @"server.bundle", 0, 0, false, false, false, false, true },
};
@implementation AppDelegate
diff --git a/cpp/test/uwp/MainPage.xaml.cpp b/cpp/test/uwp/MainPage.xaml.cpp
index 303174816cc..5561f5b25c1 100644
--- a/cpp/test/uwp/MainPage.xaml.cpp
+++ b/cpp/test/uwp/MainPage.xaml.cpp
@@ -796,6 +796,7 @@ MainPage::MainPage() :
_messages(ref new Vector<String^>())
{
InitializeComponent();
+ Ice::registerIceSSL();
}
void
diff --git a/csharp/allTests.py b/csharp/allTests.py
index 0345b6be58b..1dd37b2f83a 100755
--- a/csharp/allTests.py
+++ b/csharp/allTests.py
@@ -65,7 +65,7 @@ tests = [
("Ice/plugin", ["core"]),
("Ice/optional", ["core"]),
("Ice/admin", ["core"]),
- ("Ice/metrics", ["core", "nossl", "nows", "noipv6", "nocompress", "nosocks"]),
+ ("Ice/metrics", ["core", "nows", "noipv6", "nocompress", "nosocks"]),
("Ice/enums", ["core"]),
("Ice/serialize", ["core"]),
("Ice/networkProxy", ["core", "noipv6", "nosocks"]),
diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs
index 93f6efb87cb..ba5668eac74 100644
--- a/csharp/src/Ice/ConnectionI.cs
+++ b/csharp/src/Ice/ConnectionI.cs
@@ -2702,9 +2702,12 @@ namespace Ice
{
_info = new ConnectionInfo();
}
- _info.connectionId = _endpoint.connectionId();
- _info.adapterName = _adapter != null ? _adapter.getName() : "";
- _info.incoming = _connector == null;
+ for(ConnectionInfo info = _info; info != null; info = info.underlying)
+ {
+ info.connectionId = _endpoint.connectionId();
+ info.adapterName = _adapter != null ? _adapter.getName() : "";
+ info.incoming = _connector == null;
+ }
return _info;
}
diff --git a/csharp/src/Ice/EndpointFactory.cs b/csharp/src/Ice/EndpointFactory.cs
index c3bae69ecbe..613a9e66b9c 100644
--- a/csharp/src/Ice/EndpointFactory.cs
+++ b/csharp/src/Ice/EndpointFactory.cs
@@ -19,7 +19,7 @@ namespace IceInternal
EndpointI read(Ice.InputStream s);
void destroy();
- EndpointFactory clone(ProtocolInstance instance);
+ EndpointFactory clone(ProtocolInstance instance, EndpointFactory del);
}
}
diff --git a/csharp/src/Ice/EndpointI.cs b/csharp/src/Ice/EndpointI.cs
index 926e547ddff..ca009e6fba7 100644
--- a/csharp/src/Ice/EndpointI.cs
+++ b/csharp/src/Ice/EndpointI.cs
@@ -60,7 +60,13 @@ namespace IceInternal
//
// Marshal the endpoint.
//
- public abstract void streamWrite(Ice.OutputStream s);
+ virtual public void streamWrite(Ice.OutputStream s)
+ {
+ s.startEncapsulation();
+ streamWriteImpl(s);
+ s.endEncapsulation();
+ }
+ public abstract void streamWriteImpl(Ice.OutputStream s);
//
// Return the endpoint type.
diff --git a/csharp/src/Ice/IPEndpointI.cs b/csharp/src/Ice/IPEndpointI.cs
index 3a0263407bd..874bdc5f069 100644
--- a/csharp/src/Ice/IPEndpointI.cs
+++ b/csharp/src/Ice/IPEndpointI.cs
@@ -80,13 +80,6 @@ namespace IceInternal
return info;
}
- public override void streamWrite(Ice.OutputStream s)
- {
- s.startEncapsulation();
- streamWriteImpl(s);
- s.endEncapsulation();
- }
-
public override short type()
{
return instance_.type();
@@ -249,17 +242,7 @@ namespace IceInternal
return string.Compare(connectionId_, p.connectionId_, StringComparison.Ordinal);
}
- public string host()
- {
- return host_;
- }
-
- public int port()
- {
- return port_;
- }
-
- public virtual void streamWriteImpl(Ice.OutputStream s)
+ public override void streamWriteImpl(Ice.OutputStream s)
{
s.writeString(host_);
s.writeInt(port_);
diff --git a/csharp/src/Ice/Incoming.cs b/csharp/src/Ice/Incoming.cs
index 1f4c24c7fb7..47d892986af 100644
--- a/csharp/src/Ice/Incoming.cs
+++ b/csharp/src/Ice/Incoming.cs
@@ -227,12 +227,10 @@ namespace IceInternal
output.print("\noperation: " + current_.operation);
if(current_.con != null)
{
- Ice.ConnectionInfo connInfo = current_.con.getInfo();
- if(connInfo is Ice.IPConnectionInfo)
+ for(Ice.ConnectionInfo p = current_.con.getInfo(); p != null; p = p.underlying)
{
- Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo;
- output.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " +
- ipConnInfo.remotePort.ToString());
+ Ice.IPConnectionInfo ipinfo = p as Ice.IPConnectionInfo;
+ output.print("\nremote host: " + ipinfo.remoteAddress + " remote port: " + ipinfo.remotePort);
}
}
output.print("\n");
diff --git a/csharp/src/Ice/Instance.cs b/csharp/src/Ice/Instance.cs
index 4aef3c883d5..09d3a9a83b1 100644
--- a/csharp/src/Ice/Instance.cs
+++ b/csharp/src/Ice/Instance.cs
@@ -952,13 +952,13 @@ namespace IceInternal
if(tcpFactory != null)
{
ProtocolInstance instance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance)));
+ _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance, null)));
}
EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value);
if(sslFactory != null)
{
ProtocolInstance instance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance)));
+ _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance, null)));
}
//
diff --git a/csharp/src/Ice/InstrumentationI.cs b/csharp/src/Ice/InstrumentationI.cs
index 74cfc36382f..3eca65b7ed6 100644
--- a/csharp/src/Ice/InstrumentationI.cs
+++ b/csharp/src/Ice/InstrumentationI.cs
@@ -17,7 +17,7 @@ namespace IceInternal
using IceMX;
public class ObserverWithDelegate<T, O> : Observer<T>
- where T : Metrics, new()
+ where T : Metrics, new()
where O : Ice.Instrumentation.Observer
{
override public void
@@ -40,7 +40,7 @@ namespace IceInternal
}
}
- override public void
+ override public void
failed(string exceptionName)
{
base.failed(exceptionName);
@@ -80,7 +80,7 @@ namespace IceInternal
}
public class ObserverFactoryWithDelegate<T, OImpl, O> : ObserverFactory<T, OImpl>
- where T : Metrics, new()
+ where T : Metrics, new()
where OImpl : ObserverWithDelegate<T, O>, O, new()
where O : Ice.Instrumentation.Observer
{
@@ -124,7 +124,7 @@ namespace IceInternal
r.add("endpointIsSecure", cl.GetMethod("getEndpointInfo"), cli.GetMethod("secure"));
r.add("endpointTimeout", cl.GetMethod("getEndpointInfo"), cli.GetField("timeout"));
r.add("endpointCompress", cl.GetMethod("getEndpointInfo"), cli.GetField("compress"));
-
+
cli = typeof(Ice.IPEndpointInfo);
r.add("endpointHost", cl.GetMethod("getEndpointInfo"), cli.GetField("host"));
r.add("endpointPort", cl.GetMethod("getEndpointInfo"), cli.GetField("port"));
@@ -137,17 +137,17 @@ namespace IceInternal
r.add("incoming", cl.GetMethod("getConnectionInfo"), cli.GetField("incoming"));
r.add("adapterName", cl.GetMethod("getConnectionInfo"), cli.GetField("adapterName"));
r.add("connectionId", cl.GetMethod("getConnectionInfo"), cli.GetField("connectionId"));
-
+
cli = typeof(Ice.IPConnectionInfo);
r.add("localHost", cl.GetMethod("getConnectionInfo"), cli.GetField("localAddress"));
r.add("localPort", cl.GetMethod("getConnectionInfo"), cli.GetField("localPort"));
r.add("remoteHost", cl.GetMethod("getConnectionInfo"), cli.GetField("remoteAddress"));
r.add("remotePort", cl.GetMethod("getConnectionInfo"), cli.GetField("remotePort"));
-
+
cli = typeof(Ice.UDPConnectionInfo);
r.add("mcastHost", cl.GetMethod("getConnectionInfo"), cli.GetField("mcastAddress"));
r.add("mcastPort", cl.GetMethod("getConnectionInfo"), cli.GetField("mcastPort"));
-
+
AttrsUtil.addEndpointAttributes<T>(r, cl);
}
}
@@ -173,8 +173,8 @@ namespace IceInternal
}
}
static AttributeResolver _attributes = new AttributeResolverI();
-
- public ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state)
+
+ public ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state)
: base(_attributes)
{
_connectionInfo = con;
@@ -187,9 +187,9 @@ namespace IceInternal
if(_id == null)
{
StringBuilder os = new StringBuilder();
- if(_connectionInfo is Ice.IPConnectionInfo)
+ Ice.IPConnectionInfo info = getIPConnectionInfo();
+ if(info != null)
{
- Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)_connectionInfo;
os.Append(info.localAddress).Append(':').Append(info.localPort);
os.Append(" -> ");
os.Append(info.remoteAddress).Append(':').Append(info.remotePort);
@@ -226,7 +226,7 @@ namespace IceInternal
return "";
}
}
-
+
public string getParent()
{
if(_connectionInfo.adapterName != null && _connectionInfo.adapterName.Length > 0)
@@ -238,7 +238,7 @@ namespace IceInternal
return "Communicator";
}
}
-
+
public Ice.ConnectionInfo getConnectionInfo()
{
return _connectionInfo;
@@ -258,6 +258,19 @@ namespace IceInternal
return _endpointInfo;
}
+ private Ice.IPConnectionInfo
+ getIPConnectionInfo()
+ {
+ for(Ice.ConnectionInfo p = _connectionInfo; p != null; p = p.underlying)
+ {
+ if(p is Ice.IPConnectionInfo)
+ {
+ return (Ice.IPConnectionInfo)p;
+ }
+ }
+ return null;
+ }
+
readonly private Ice.ConnectionInfo _connectionInfo;
readonly private Ice.Endpoint _endpoint;
readonly private Ice.Instrumentation.ConnectionState _state;
@@ -276,9 +289,9 @@ namespace IceInternal
Type cl = typeof(DispatchHelper);
add("parent", cl.GetMethod("getParent"));
add("id", cl.GetMethod("getId"));
-
+
AttrsUtil.addConnectionAttributes<DispatchMetrics>(this, cl);
-
+
Type clc = typeof(Ice.Current);
add("operation", cl.GetMethod("getCurrent"), clc.GetField("operation"));
add("identity", cl.GetMethod("getIdentity"));
@@ -293,7 +306,7 @@ namespace IceInternal
}
}
static AttributeResolver _attributes = new AttributeResolverI();
-
+
public DispatchHelper(Ice.Current current, int size) : base(_attributes)
{
_current = current;
@@ -317,7 +330,7 @@ namespace IceInternal
{
v.size += _size;
}
-
+
public string getMode()
{
return _current.requestId == 0 ? "oneway" : "twoway";
@@ -342,7 +355,7 @@ namespace IceInternal
{
return _current.adapter.getName();
}
-
+
public Ice.ConnectionInfo getConnectionInfo()
{
if(_current.con != null)
@@ -351,7 +364,7 @@ namespace IceInternal
}
return null;
}
-
+
public Ice.Endpoint getEndpoint()
{
if(_current.con != null)
@@ -365,7 +378,7 @@ namespace IceInternal
{
return _current.con;
}
-
+
public Ice.EndpointInfo getEndpointInfo()
{
if(_current.con != null && _endpointInfo == null)
@@ -379,12 +392,12 @@ namespace IceInternal
{
return _current;
}
-
+
public string getIdentity()
{
return _current.adapter.getCommunicator().identityToString(_current.id);
}
-
+
readonly private Ice.Current _current;
readonly private int _size;
private string _id;
@@ -394,7 +407,7 @@ namespace IceInternal
class InvocationHelper : MetricsHelper<InvocationMetrics>
{
class AttributeResolverI : MetricsHelper<InvocationMetrics>.AttributeResolver
- {
+ {
public AttributeResolverI()
{
try
@@ -402,10 +415,10 @@ namespace IceInternal
Type cl = typeof(InvocationHelper);
add("parent", cl.GetMethod("getParent"));
add("id", cl.GetMethod("getId"));
-
+
add("operation", cl.GetMethod("getOperation"));
add("identity", cl.GetMethod("getIdentity"));
-
+
Type cli = typeof(Ice.ObjectPrx);
add("facet", cl.GetMethod("getProxy"), cli.GetMethod("ice_getFacet"));
add("encoding", cl.GetMethod("getEncodingVersion"));
@@ -419,7 +432,7 @@ namespace IceInternal
}
}
static AttributeResolver _attributes = new AttributeResolverI();
-
+
public InvocationHelper(Ice.ObjectPrx proxy, string op, Dictionary<string, string> ctx) : base(_attributes)
{
_proxy = proxy;
@@ -439,34 +452,34 @@ namespace IceInternal
}
throw new ArgumentOutOfRangeException(attribute);
}
-
+
public string getMode()
{
if(_proxy == null)
{
throw new ArgumentOutOfRangeException("mode");
}
-
+
if(_proxy.ice_isTwoway())
{
return "twoway";
- }
+ }
else if(_proxy.ice_isOneway())
{
return "oneway";
- }
+ }
else if(_proxy.ice_isBatchOneway())
{
return "batch-oneway";
- }
+ }
else if(_proxy.ice_isDatagram())
{
return "datagram";
- }
+ }
else if(_proxy.ice_isBatchDatagram())
{
return "batch-datagram";
- }
+ }
else
{
throw new ArgumentOutOfRangeException("mode");
@@ -499,12 +512,12 @@ namespace IceInternal
}
return _id;
}
-
+
public string getParent()
{
return "Communicator";
}
-
+
public Ice.ObjectPrx getProxy()
{
return _proxy;
@@ -514,7 +527,7 @@ namespace IceInternal
{
return Ice.Util.encodingVersionToString(_proxy.ice_getEncodingVersion());
}
-
+
public string getIdentity()
{
if(_proxy != null)
@@ -526,12 +539,12 @@ namespace IceInternal
return "";
}
}
-
+
public string getOperation()
{
return _operation;
}
-
+
readonly private Ice.ObjectPrx _proxy;
readonly private string _operation;
readonly private Dictionary<string, string> _context;
@@ -539,11 +552,11 @@ namespace IceInternal
readonly static private Ice.Endpoint[] emptyEndpoints = new Ice.Endpoint[0];
}
-
+
class ThreadHelper : MetricsHelper<ThreadMetrics>
{
class AttributeResolverI : MetricsHelper<ThreadMetrics>.AttributeResolver
- {
+ {
public AttributeResolverI()
{
try
@@ -584,7 +597,7 @@ namespace IceInternal
break;
}
}
-
+
readonly public string _parent;
readonly public string _id;
readonly private Ice.Instrumentation.ThreadState _state;
@@ -593,7 +606,7 @@ namespace IceInternal
class EndpointHelper : MetricsHelper<Metrics>
{
class AttributeResolverI : MetricsHelper<Metrics>.AttributeResolver
- {
+ {
public AttributeResolverI()
{
try
@@ -621,7 +634,7 @@ namespace IceInternal
{
_endpoint = endpt;
}
-
+
public Ice.EndpointInfo getEndpointInfo()
{
if(_endpointInfo == null)
@@ -635,7 +648,7 @@ namespace IceInternal
{
return "Communicator";
}
-
+
public string getId()
{
if(_id == null)
@@ -644,21 +657,21 @@ namespace IceInternal
}
return _id;
}
-
+
public string getEndpoint()
{
return _endpoint.ToString();
}
-
+
readonly private Ice.Endpoint _endpoint;
private string _id;
private Ice.EndpointInfo _endpointInfo;
}
-
+
public class RemoteInvocationHelper : MetricsHelper<RemoteMetrics>
{
class AttributeResolverI : MetricsHelper<RemoteMetrics>.AttributeResolver
- {
+ {
public AttributeResolverI()
{
try
@@ -708,7 +721,7 @@ namespace IceInternal
{
return _requestId;
}
-
+
public string getParent()
{
if(_connectionInfo.adapterName != null && _connectionInfo.adapterName.Length > 0)
@@ -720,12 +733,12 @@ namespace IceInternal
return "Communicator";
}
}
-
+
public Ice.ConnectionInfo getConnectionInfo()
{
return _connectionInfo;
}
-
+
public Ice.Endpoint getEndpoint()
{
return _endpoint;
@@ -751,7 +764,7 @@ namespace IceInternal
public class CollocatedInvocationHelper : MetricsHelper<CollocatedMetrics>
{
class AttributeResolverI : MetricsHelper<CollocatedMetrics>.AttributeResolver
- {
+ {
public AttributeResolverI()
{
try
@@ -791,12 +804,12 @@ namespace IceInternal
{
return _requestId;
}
-
+
public string getParent()
{
return "Communicator";
}
-
+
readonly private int _size;
readonly private int _requestId;
readonly private string _id;
@@ -925,8 +938,8 @@ namespace IceInternal
delegate_.retried();
}
}
-
- public Ice.Instrumentation.RemoteObserver getRemoteObserver(Ice.ConnectionInfo con, Ice.Endpoint endpt,
+
+ public Ice.Instrumentation.RemoteObserver getRemoteObserver(Ice.ConnectionInfo con, Ice.Endpoint endpt,
int requestId, int size)
{
Ice.Instrumentation.RemoteObserver del = null;
@@ -934,14 +947,14 @@ namespace IceInternal
{
del = delegate_.getRemoteObserver(con, endpt, requestId, size);
}
- return getObserver<RemoteMetrics, RemoteObserverI,
- Ice.Instrumentation.RemoteObserver>("Remote",
+ return getObserver<RemoteMetrics, RemoteObserverI,
+ Ice.Instrumentation.RemoteObserver>("Remote",
new RemoteInvocationHelper(con, endpt, requestId, size),
del);
}
- public Ice.Instrumentation.CollocatedObserver getCollocatedObserver(Ice.ObjectAdapter adapter,
- int requestId,
+ public Ice.Instrumentation.CollocatedObserver getCollocatedObserver(Ice.ObjectAdapter adapter,
+ int requestId,
int size)
{
Ice.Instrumentation.CollocatedObserver del = null;
@@ -950,7 +963,7 @@ namespace IceInternal
del = delegate_.getCollocatedObserver(adapter, requestId, size);
}
return getObserver<CollocatedMetrics, CollocatedObserverI,
- Ice.Instrumentation.CollocatedObserver>("Collocated",
+ Ice.Instrumentation.CollocatedObserver>("Collocated",
new CollocatedInvocationHelper(adapter, requestId, size),
del);
}
@@ -1088,8 +1101,8 @@ namespace IceInternal
}
return null;
}
-
- public Ice.Instrumentation.ConnectionObserver getConnectionObserver(Ice.ConnectionInfo c,
+
+ public Ice.Instrumentation.ConnectionObserver getConnectionObserver(Ice.ConnectionInfo c,
Ice.Endpoint e,
Ice.Instrumentation.ConnectionState s,
Ice.Instrumentation.ConnectionObserver obsv)
@@ -1113,9 +1126,9 @@ namespace IceInternal
}
return null;
}
-
- public Ice.Instrumentation.ThreadObserver getThreadObserver(string parent, string id,
- Ice.Instrumentation.ThreadState s,
+
+ public Ice.Instrumentation.ThreadObserver getThreadObserver(string parent, string id,
+ Ice.Instrumentation.ThreadState s,
Ice.Instrumentation.ThreadObserver obsv)
{
if(_threads.isEnabled())
@@ -1137,8 +1150,8 @@ namespace IceInternal
}
return null;
}
-
- public Ice.Instrumentation.InvocationObserver getInvocationObserver(Ice.ObjectPrx prx, string operation,
+
+ public Ice.Instrumentation.InvocationObserver getInvocationObserver(Ice.ObjectPrx prx, string operation,
Dictionary<string, string> ctx)
{
if(_invocations.isEnabled())
@@ -1159,7 +1172,7 @@ namespace IceInternal
}
return null;
}
-
+
public Ice.Instrumentation.DispatchObserver getDispatchObserver(Ice.Current c, int size)
{
if(_dispatch.isEnabled())
@@ -1180,7 +1193,7 @@ namespace IceInternal
}
return null;
}
-
+
public void setObserverUpdater(Ice.Instrumentation.ObserverUpdater updater)
{
if(updater == null)
diff --git a/csharp/src/Ice/MetricsObserverI.cs b/csharp/src/Ice/MetricsObserverI.cs
index ad3f4ad2412..0157e163e88 100644
--- a/csharp/src/Ice/MetricsObserverI.cs
+++ b/csharp/src/Ice/MetricsObserverI.cs
@@ -24,9 +24,9 @@ namespace IceMX
{
_name = name;
}
-
+
protected abstract object resolve(object obj);
-
+
public string resolveImpl(object obj)
{
try
@@ -47,7 +47,34 @@ namespace IceMX
throw new ArgumentOutOfRangeException(_name, ex);
}
}
-
+
+ protected object getField(System.Reflection.FieldInfo field, object obj)
+ {
+ while(obj != null)
+ {
+ try
+ {
+ return field.GetValue(obj);
+ }
+ catch(ArgumentException ex)
+ {
+ if(obj is Ice.EndpointInfo)
+ {
+ obj = ((Ice.EndpointInfo)obj).underlying;
+ }
+ else if(obj is Ice.ConnectionInfo)
+ {
+ obj = ((Ice.ConnectionInfo)obj).underlying;
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ }
+ return null;
+ }
+
readonly protected string _name;
}
@@ -58,15 +85,15 @@ namespace IceMX
Debug.Assert(field != null);
_field = field;
}
-
+
override protected object resolve(object obj)
{
- return _field.GetValue(obj);
+ return getField(_field, obj);
}
-
+
readonly private System.Reflection.FieldInfo _field;
}
-
+
class MethodResolverI : Resolver
{
internal MethodResolverI(string name, System.Reflection.MethodInfo method) : base(name)
@@ -74,12 +101,12 @@ namespace IceMX
Debug.Assert(method != null);
_method = method;
}
-
+
override protected object resolve(object obj)
{
return _method.Invoke(obj, null);
}
-
+
readonly private System.Reflection.MethodInfo _method;
}
@@ -93,24 +120,24 @@ namespace IceMX
_method = method;
_field = field;
}
-
+
override protected object resolve(object obj)
{
object o = _method.Invoke(obj, null);
if(o != null)
{
- return _field.GetValue(o);
+ return getField(_field, o);
}
throw new ArgumentOutOfRangeException(_name);
}
-
+
readonly private System.Reflection.MethodInfo _method;
readonly private System.Reflection.FieldInfo _field;
}
-
+
class MemberMethodResolverI : Resolver
{
- internal MemberMethodResolverI(string name, System.Reflection.MethodInfo method,
+ internal MemberMethodResolverI(string name, System.Reflection.MethodInfo method,
System.Reflection.MethodInfo subMeth)
: base(name)
{
@@ -118,7 +145,7 @@ namespace IceMX
_method = method;
_subMethod = subMeth;
}
-
+
override protected object resolve(object obj)
{
object o = _method.Invoke(obj, null);
@@ -128,7 +155,7 @@ namespace IceMX
}
throw new ArgumentOutOfRangeException(_name);
}
-
+
readonly private System.Reflection.MethodInfo _method;
readonly private System.Reflection.MethodInfo _subMethod;
}
@@ -155,26 +182,26 @@ namespace IceMX
}
return resolver.resolveImpl(helper);
}
-
- public void
+
+ public void
add(string name, System.Reflection.MethodInfo method)
{
_attributes.Add(name, new MethodResolverI(name, method));
}
-
- public void
+
+ public void
add(string name, System.Reflection.FieldInfo field)
{
_attributes.Add(name, new FieldResolverI(name, field));
}
-
- public void
+
+ public void
add(string name, System.Reflection.MethodInfo method, System.Reflection.FieldInfo field)
{
_attributes.Add(name, new MemberFieldResolverI(name, method, field));
}
-
- public void
+
+ public void
add(string name, System.Reflection.MethodInfo method, System.Reflection.MethodInfo subMethod)
{
_attributes.Add(name, new MemberMethodResolverI(name, method, subMethod));
@@ -209,7 +236,7 @@ namespace IceMX
public class Observer<T> : Stopwatch, Ice.Instrumentation.Observer where T : Metrics, new()
{
public delegate void MetricsUpdate(T m);
-
+
virtual public void attach()
{
Start();
@@ -232,7 +259,7 @@ namespace IceMX
e.failed(exceptionName);
}
}
-
+
public void forEach(MetricsUpdate u)
{
foreach(MetricsMap<T>.Entry e in _objects)
@@ -249,7 +276,7 @@ namespace IceMX
{
return;
}
-
+
_previousDelay = previous._previousDelay + (long)(previous.ElapsedTicks / (Frequency / 1000000.0));
foreach(MetricsMap<T>.Entry e in previous._objects)
{
@@ -259,7 +286,7 @@ namespace IceMX
}
}
}
-
+
public ObserverImpl getObserver<S, ObserverImpl>(string mapName, MetricsHelper<S> helper)
where S : Metrics, new()
where ObserverImpl : Observer<S>, new()
@@ -307,7 +334,7 @@ namespace IceMX
}
return null;
}
-
+
private List<MetricsMap<T>.Entry> _objects;
private long _previousDelay = 0;
}
@@ -365,7 +392,7 @@ namespace IceMX
metricsObjects.Add(e);
}
}
-
+
if(metricsObjects == null)
{
if(old != null)
@@ -428,7 +455,7 @@ namespace IceMX
_updater = updater;
}
}
-
+
private readonly IceInternal.MetricsAdminI _metrics;
private readonly string _name;
private List<MetricsMap<T>> _maps = new List<MetricsMap<T>>();
diff --git a/csharp/src/Ice/OpaqueEndpointI.cs b/csharp/src/Ice/OpaqueEndpointI.cs
index 020878a3e38..a8749d4ec17 100644
--- a/csharp/src/Ice/OpaqueEndpointI.cs
+++ b/csharp/src/Ice/OpaqueEndpointI.cs
@@ -13,6 +13,7 @@ namespace IceInternal
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
+ using System.Diagnostics;
sealed class OpaqueEndpointI : EndpointI
{
@@ -57,6 +58,11 @@ namespace IceInternal
s.endEncapsulation();
}
+ public override void streamWriteImpl(Ice.OutputStream s)
+ {
+ Debug.Assert(false);
+ }
+
//
// Convert the endpoint to its string form
//
@@ -69,7 +75,7 @@ namespace IceInternal
private sealed class InfoI : Ice.OpaqueEndpointInfo
{
public InfoI(short type, Ice.EncodingVersion rawEncoding, byte[] rawBytes) :
- base(-1, false, rawEncoding, rawBytes)
+ base(null, -1, false, rawEncoding, rawBytes)
{
_type = type;
}
diff --git a/csharp/src/Ice/TcpEndpointI.cs b/csharp/src/Ice/TcpEndpointI.cs
index bb8c0e18638..579ab230366 100644
--- a/csharp/src/Ice/TcpEndpointI.cs
+++ b/csharp/src/Ice/TcpEndpointI.cs
@@ -13,7 +13,7 @@ namespace IceInternal
using System.Net;
using System.Globalization;
- sealed class TcpEndpointI : IPEndpointI, WSEndpointDelegate
+ sealed class TcpEndpointI : IPEndpointI
{
public TcpEndpointI(ProtocolInstance instance, string ho, int po, EndPoint sourceAddr, int ti, string conId,
bool co) :
@@ -62,43 +62,17 @@ namespace IceInternal
private IPEndpointI _endpoint;
}
- public override Ice.EndpointInfo getInfo()
- {
- InfoI info = new InfoI(this);
- fillEndpointInfo(info);
- return info;
- }
-
- private sealed class WSInfoI : Ice.WSEndpointInfo
+ public override void streamWriteImpl(Ice.OutputStream s)
{
- public WSInfoI(IPEndpointI e)
- {
- _endpoint = e;
- }
-
- public override short type()
- {
- return _endpoint.type();
- }
-
- public override bool datagram()
- {
- return _endpoint.datagram();
- }
-
- public override bool secure()
- {
- return _endpoint.secure();
- }
-
- private IPEndpointI _endpoint;
+ base.streamWriteImpl(s);
+ s.writeInt(_timeout);
+ s.writeBool(_compress);
}
- public Ice.EndpointInfo getWSInfo(string resource)
+ public override Ice.EndpointInfo getInfo()
{
- WSInfoI info = new WSInfoI(this);
+ InfoI info = new InfoI(this);
fillEndpointInfo(info);
- info.resource = resource;
return info;
}
@@ -219,13 +193,6 @@ namespace IceInternal
return base.CompareTo(p);
}
- public override void streamWriteImpl(Ice.OutputStream s)
- {
- base.streamWriteImpl(s);
- s.writeInt(_timeout);
- s.writeBool(_compress);
- }
-
public override void hashInit(ref int h)
{
base.hashInit(ref h);
@@ -352,7 +319,7 @@ namespace IceInternal
_instance = null;
}
- public EndpointFactory clone(ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del)
{
return new TcpEndpointFactory(instance);
}
diff --git a/csharp/src/Ice/TcpTransceiver.cs b/csharp/src/Ice/TcpTransceiver.cs
index 42cf3319890..9ac3b249040 100644
--- a/csharp/src/Ice/TcpTransceiver.cs
+++ b/csharp/src/Ice/TcpTransceiver.cs
@@ -14,7 +14,7 @@ namespace IceInternal
using System.Net;
using System.Net.Sockets;
- sealed class TcpTransceiver : Transceiver, WSTransceiverDelegate
+ sealed class TcpTransceiver : Transceiver
{
public Socket fd()
{
@@ -87,15 +87,17 @@ namespace IceInternal
public Ice.ConnectionInfo getInfo()
{
Ice.TCPConnectionInfo info = new Ice.TCPConnectionInfo();
- fillConnectionInfo(info);
- return info;
- }
-
- public Ice.ConnectionInfo getWSInfo(Dictionary<string, string> headers)
- {
- Ice.WSConnectionInfo info = new Ice.WSConnectionInfo();
- fillConnectionInfo(info);
- info.headers = headers;
+ if(_stream.fd() != null)
+ {
+ EndPoint localEndpoint = Network.getLocalAddress(_stream.fd());
+ info.localAddress = Network.endpointAddressToString(localEndpoint);
+ info.localPort = Network.endpointPort(localEndpoint);
+ EndPoint remoteEndpoint = Network.getRemoteAddress(_stream.fd());
+ info.remoteAddress = Network.endpointAddressToString(remoteEndpoint);
+ info.remotePort = Network.endpointPort(remoteEndpoint);
+ info.rcvSize = Network.getRecvBufferSize(_stream.fd());
+ info.sndSize = Network.getSendBufferSize(_stream.fd());
+ }
return info;
}
@@ -127,21 +129,6 @@ namespace IceInternal
_stream = stream;
}
- private void fillConnectionInfo(Ice.TCPConnectionInfo info)
- {
- if(_stream.fd() != null)
- {
- EndPoint localEndpoint = Network.getLocalAddress(_stream.fd());
- info.localAddress = Network.endpointAddressToString(localEndpoint);
- info.localPort = Network.endpointPort(localEndpoint);
- EndPoint remoteEndpoint = Network.getRemoteAddress(_stream.fd());
- info.remoteAddress = Network.endpointAddressToString(remoteEndpoint);
- info.remotePort = Network.endpointPort(remoteEndpoint);
- info.rcvSize = Network.getRecvBufferSize(_stream.fd());
- info.sndSize = Network.getSendBufferSize(_stream.fd());
- }
- }
-
private readonly ProtocolInstance _instance;
private readonly StreamSocket _stream;
}
diff --git a/csharp/src/Ice/UdpEndpointI.cs b/csharp/src/Ice/UdpEndpointI.cs
index 28807066dd3..bdaa9ef35e9 100644
--- a/csharp/src/Ice/UdpEndpointI.cs
+++ b/csharp/src/Ice/UdpEndpointI.cs
@@ -438,7 +438,7 @@ namespace IceInternal
_instance = null;
}
- public EndpointFactory clone(ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del)
{
return new UdpEndpointFactory(instance);
}
diff --git a/csharp/src/Ice/WSConnector.cs b/csharp/src/Ice/WSConnector.cs
index 91a51e2c400..5b1479d47cb 100644
--- a/csharp/src/Ice/WSConnector.cs
+++ b/csharp/src/Ice/WSConnector.cs
@@ -13,7 +13,7 @@ namespace IceInternal
{
public IceInternal.Transceiver connect()
{
- return new WSTransceiver(_instance, _delegate.connect(), _host, _port, _resource);
+ return new WSTransceiver(_instance, _delegate.connect(), _host, _resource);
}
public short type()
@@ -21,12 +21,11 @@ namespace IceInternal
return _delegate.type();
}
- internal WSConnector(ProtocolInstance instance, IceInternal.Connector del, string host, int port, string resource)
+ internal WSConnector(ProtocolInstance instance, IceInternal.Connector del, string host, string resource)
{
_instance = instance;
_delegate = del;
_host = host;
- _port = port;
_resource = resource;
}
@@ -69,7 +68,6 @@ namespace IceInternal
private ProtocolInstance _instance;
private IceInternal.Connector _delegate;
private string _host;
- private int _port;
private string _resource;
}
}
diff --git a/csharp/src/Ice/WSEndpoint.cs b/csharp/src/Ice/WSEndpoint.cs
index affc7d0bdfd..09b26b24acb 100644
--- a/csharp/src/Ice/WSEndpoint.cs
+++ b/csharp/src/Ice/WSEndpoint.cs
@@ -13,28 +13,19 @@ namespace IceInternal
using System.Diagnostics;
using System.Collections.Generic;
- //
- // Delegate interface implemented by TcpEndpoint or IceSSL.EndpointI or any endpoint that WS can
- // delegate to.
- //
- public interface WSEndpointDelegate
- {
- Ice.EndpointInfo getWSInfo(string resource);
- }
-
sealed class WSEndpoint : EndpointI
{
internal WSEndpoint(ProtocolInstance instance, EndpointI del, string res)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
_resource = res;
}
internal WSEndpoint(ProtocolInstance instance, EndpointI del, List<string> args)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
initWithOptions(args);
@@ -47,7 +38,7 @@ namespace IceInternal
internal WSEndpoint(ProtocolInstance instance, EndpointI del, Ice.InputStream s)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
_resource = s.readString();
}
@@ -79,8 +70,12 @@ namespace IceInternal
public override Ice.EndpointInfo getInfo()
{
- Debug.Assert(_delegate is WSEndpointDelegate);
- return ((WSEndpointDelegate)_delegate).getWSInfo(_resource);
+ Ice.WSEndpointInfo info = new InfoI(this);
+ info.underlying = _delegate.getInfo();
+ info.resource = _resource;
+ info.compress = info.underlying.compress;
+ info.timeout = info.underlying.timeout;
+ return info;
}
public override short type()
@@ -93,12 +88,10 @@ namespace IceInternal
return _delegate.protocol();
}
- public override void streamWrite(Ice.OutputStream s)
+ public override void streamWriteImpl(Ice.OutputStream s)
{
- s.startEncapsulation();
_delegate.streamWriteImpl(s);
s.writeString(_resource);
- s.endEncapsulation();
}
public override int timeout()
@@ -169,13 +162,11 @@ namespace IceInternal
private sealed class EndpointI_connectorsI : EndpointI_connectors
{
- public EndpointI_connectorsI(ProtocolInstance instance, string host, int port, string resource,
- EndpointI_connectors cb)
+ public EndpointI_connectorsI(ProtocolInstance instance, string host, string res, EndpointI_connectors cb)
{
_instance = instance;
_host = host;
- _port = port;
- _resource = resource;
+ _resource = res;
_callback = cb;
}
@@ -184,7 +175,7 @@ namespace IceInternal
List<Connector> l = new List<Connector>();
foreach(Connector c in connectors)
{
- l.Add(new WSConnector(_instance, c, _host, _port, _resource));
+ l.Add(new WSConnector(_instance, c, _host, _resource));
}
_callback.connectors(l);
}
@@ -196,23 +187,27 @@ namespace IceInternal
private ProtocolInstance _instance;
private string _host;
- private int _port;
private string _resource;
private EndpointI_connectors _callback;
}
- public override void connectors_async(Ice.EndpointSelectionType selType,
- EndpointI_connectors callback)
+ public override void connectors_async(Ice.EndpointSelectionType selType, EndpointI_connectors callback)
{
- EndpointI_connectorsI cb =
- new EndpointI_connectorsI(_instance, _delegate.host(), _delegate.port(), _resource, callback);
- _delegate.connectors_async(selType, cb);
+ string host = "";
+ for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p is Ice.IPEndpointInfo)
+ {
+ Ice.IPEndpointInfo ipInfo = (Ice.IPEndpointInfo)p;
+ host = ipInfo.host + ":" + ipInfo.port;
+ }
+ }
+ _delegate.connectors_async(selType, new EndpointI_connectorsI(_instance, host, _resource, callback));
}
public override Acceptor acceptor(string adapterName)
{
- Acceptor delAcc = _delegate.acceptor(adapterName);
- return new WSAcceptor(this, _instance, delAcc);
+ return new WSAcceptor(this, _instance, _delegate.acceptor(adapterName));
}
public WSEndpoint endpoint(EndpointI delEndp)
@@ -299,11 +294,6 @@ namespace IceInternal
return _delegate.CompareTo(p._delegate);
}
- public EndpointI getDelegate()
- {
- return _delegate;
- }
-
protected override bool checkOption(string option, string argument, string endpoint)
{
switch(option[1])
@@ -328,7 +318,7 @@ namespace IceInternal
}
private ProtocolInstance _instance;
- private IPEndpointI _delegate;
+ private EndpointI _delegate;
private string _resource;
}
@@ -366,10 +356,9 @@ namespace IceInternal
_instance = null;
}
- public EndpointFactory clone(ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del)
{
- Debug.Assert(false); // We don't support cloning this transport.
- return null;
+ return new WSEndpointFactory(instance, del);
}
private ProtocolInstance _instance;
diff --git a/csharp/src/Ice/WSTransceiver.cs b/csharp/src/Ice/WSTransceiver.cs
index 761cb164264..7945d22d684 100644
--- a/csharp/src/Ice/WSTransceiver.cs
+++ b/csharp/src/Ice/WSTransceiver.cs
@@ -16,15 +16,6 @@ namespace IceInternal
using System.Security.Cryptography;
using System.Text;
- //
- // Delegate interface implemented by TcpTransceiver or IceSSL.TransceiverI or any endpoint that WS can
- // delegate to.
- //
- public interface WSTransceiverDelegate
- {
- Ice.ConnectionInfo getWSInfo(Dictionary<string, string> headers);
- }
-
sealed class WSTransceiver : Transceiver
{
public Socket fd()
@@ -70,9 +61,7 @@ namespace IceInternal
//
StringBuilder @out = new StringBuilder();
@out.Append("GET " + _resource + " HTTP/1.1\r\n");
- @out.Append("Host: " + _host + ":");
- @out.Append(_port);
- @out.Append("\r\n");
+ @out.Append("Host: " + _host + "\r\n");
@out.Append("Upgrade: websocket\r\n");
@out.Append("Connection: Upgrade\r\n");
@out.Append("Sec-WebSocket-Protocol: " + _iceProtocol + "\r\n");
@@ -665,8 +654,10 @@ namespace IceInternal
public Ice.ConnectionInfo getInfo()
{
- Debug.Assert(_delegate is WSTransceiverDelegate);
- return ((WSTransceiverDelegate)_delegate).getWSInfo(_parser.getHeaders());
+ Ice.WSConnectionInfo info = new Ice.WSConnectionInfo();
+ info.headers = _parser.getHeaders();
+ info.underlying = _delegate.getInfo();
+ return info;
}
public void checkSendSize(Buffer buf)
@@ -690,11 +681,10 @@ namespace IceInternal
}
internal
- WSTransceiver(ProtocolInstance instance, Transceiver del, string host, int port, string resource)
+ WSTransceiver(ProtocolInstance instance, Transceiver del, string host, string resource)
{
init(instance, del);
_host = host;
- _port = port;
_resource = resource;
_incoming = false;
@@ -718,7 +708,6 @@ namespace IceInternal
{
init(instance, del);
_host = "";
- _port = -1;
_resource = "";
_incoming = true;
@@ -1619,7 +1608,6 @@ namespace IceInternal
private ProtocolInstance _instance;
private Transceiver _delegate;
private string _host;
- private int _port;
private string _resource;
private bool _incoming;
diff --git a/csharp/src/IceSSL/AcceptorI.cs b/csharp/src/IceSSL/AcceptorI.cs
index 3539b3e8782..f0f50b84b45 100644
--- a/csharp/src/IceSSL/AcceptorI.cs
+++ b/csharp/src/IceSSL/AcceptorI.cs
@@ -12,38 +12,17 @@ namespace IceSSL
using System;
using System.Collections.Generic;
using System.Diagnostics;
- using System.IO;
- using System.Net;
- using System.Net.Security;
- using System.Net.Sockets;
- using System.Security.Cryptography.X509Certificates;
- using System.Text;
class AcceptorI : IceInternal.Acceptor
{
public void close()
{
- Debug.Assert(_acceptFd == null);
- if(_fd != null)
- {
- IceInternal.Network.closeSocketNoThrow(_fd);
- _fd = null;
- }
+ _delegate.close();
}
public IceInternal.EndpointI listen()
{
- try
- {
- _addr = IceInternal.Network.doBind(_fd, _addr);
- IceInternal.Network.doListen(_fd, _backlog);
- }
- catch(SystemException)
- {
- _fd = null;
- throw;
- }
- _endpoint = _endpoint.endpoint(this);
+ _endpoint = _endpoint.endpoint(_delegate.listen());
return _endpoint;
}
@@ -58,144 +37,55 @@ namespace IceSSL
ex.reason = "IceSSL: plug-in is not initialized";
throw ex;
}
-
- try
- {
- _result = _fd.BeginAccept(delegate(IAsyncResult result)
- {
- if(!result.CompletedSynchronously)
- {
- callback(result.AsyncState);
- }
- }, state);
- return _result.CompletedSynchronously;
- }
- catch(SocketException ex)
- {
- throw new Ice.SocketException(ex);
- }
+ return _delegate.startAccept(callback, state);
}
public void finishAccept()
{
- if(_fd != null)
- {
- Debug.Assert(_result != null);
- try
- {
- _acceptFd = _fd.EndAccept(_result);
- _result = null;
- }
- catch(SocketException ex)
- {
- _acceptError = ex;
- }
- }
+ _delegate.finishAccept();
}
public IceInternal.Transceiver accept()
{
- if(_acceptFd == null)
- {
- throw _acceptError;
- }
-
- Socket acceptFd = _acceptFd;
- _acceptFd = null;
- _acceptError = null;
- return new TransceiverI(_instance, new IceInternal.StreamSocket(_instance, acceptFd), _adapterName, true);
+ return new TransceiverI(_instance, _delegate.accept(), _adapterName, true);
}
public string protocol()
{
- return _instance.protocol();
+ return _delegate.protocol();
}
public override string ToString()
{
- return IceInternal.Network.addrToString(_addr);
+ return _delegate.ToString();
}
public string toDetailedString()
{
- StringBuilder s = new StringBuilder("local address = ");
- s.Append(ToString());
-
- List<string> intfs = IceInternal.Network.getHostsForEndpointExpand(_addr.Address.ToString(),
- _instance.protocolSupport(),
- true);
- if(intfs.Count != 0)
- {
- s.Append("\nlocal interfaces = ");
- s.Append(String.Join(", ", intfs.ToArray()));
- }
- return s.ToString();
+ return _delegate.toDetailedString();
}
- internal int effectivePort()
- {
- return _addr.Port;
- }
-
- internal AcceptorI(EndpointI endpoint, Instance instance, string adapterName, string host, int port)
+ internal AcceptorI(EndpointI endpoint, Instance instance, IceInternal.Acceptor del, string adapterName)
{
_endpoint = endpoint;
+ _delegate = del;
_instance = instance;
_adapterName = adapterName;
- _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);
//
// .NET requires that a certificate be supplied.
//
- X509Certificate2Collection certs = instance.certs();
- if(certs.Count == 0)
+ if(instance.certs().Count == 0)
{
Ice.SecurityException ex = new Ice.SecurityException();
ex.reason = "IceSSL: certificate required for server endpoint";
throw ex;
}
-
- try
- {
- int protocol = instance.protocolSupport();
- _addr = IceInternal.Network.getAddressForServer(host, port, protocol, instance.preferIPv6()) as
- IPEndPoint;
- _fd = IceInternal.Network.createServerSocket(false, _addr.AddressFamily, protocol);
- IceInternal.Network.setBlock(_fd, false);
- IceInternal.Network.setTcpBufSize(_fd, _instance);
- if(IceInternal.AssemblyUtil.platform_ != IceInternal.AssemblyUtil.Platform.Windows)
- {
- //
- // Enable SO_REUSEADDR on Unix platforms to allow
- // re-using the socket even if it's in the TIME_WAIT
- // state. On Windows, this doesn't appear to be
- // necessary and enabling SO_REUSEADDR would actually
- // not be a good thing since it allows a second
- // process to bind to an address even it's already
- // bound by another process.
- //
- // TODO: using SO_EXCLUSIVEADDRUSE on Windows would
- // probably be better but it's only supported by recent
- // Windows versions (XP SP2, Windows Server 2003).
- //
- IceInternal.Network.setReuseAddress(_fd, true);
- }
- }
- catch(System.Exception)
- {
- _fd = null;
- throw;
- }
}
private EndpointI _endpoint;
+ private IceInternal.Acceptor _delegate;
private Instance _instance;
private string _adapterName;
- private Socket _fd;
- private Socket _acceptFd;
- private System.Exception _acceptError;
- private int _backlog;
- private IPEndPoint _addr;
- private IAsyncResult _result;
}
}
diff --git a/csharp/src/IceSSL/ConnectorI.cs b/csharp/src/IceSSL/ConnectorI.cs
index bac3ad376db..ca68ea09acc 100644
--- a/csharp/src/IceSSL/ConnectorI.cs
+++ b/csharp/src/IceSSL/ConnectorI.cs
@@ -29,37 +29,22 @@ namespace IceSSL
throw ex;
}
- return new TransceiverI(_instance, new IceInternal.StreamSocket(_instance, _proxy, _addr, _sourceAddr),
- _host, false);
+ return new TransceiverI(_instance, _delegate.connect(), _host, false);
}
public short type()
{
- return _instance.type();
+ return _delegate.type();
}
//
// Only for use by EndpointI.
//
- internal ConnectorI(Instance instance, string host, EndPoint addr, IceInternal.NetworkProxy proxy,
- EndPoint sourceAddr, int timeout, string conId)
+ internal ConnectorI(Instance instance, IceInternal.Connector del, string host)
{
_instance = instance;
+ _delegate = del;
_host = host;
- _addr = (IPEndPoint)addr;
- _proxy = proxy;
- _sourceAddr = sourceAddr;
- _timeout = timeout;
- _connectionId = conId;
-
- _hashCode = 5381;
- IceInternal.HashUtil.hashAdd(ref _hashCode, _addr);
- if(_sourceAddr != null)
- {
- IceInternal.HashUtil.hashAdd(ref _hashCode, _sourceAddr);
- }
- IceInternal.HashUtil.hashAdd(ref _hashCode, _timeout);
- IceInternal.HashUtil.hashAdd(ref _hashCode, _connectionId);
}
public override bool Equals(object obj)
@@ -75,41 +60,21 @@ namespace IceSSL
}
ConnectorI p = (ConnectorI)obj;
- if(_timeout != p._timeout)
- {
- return false;
- }
-
- if(!_connectionId.Equals(p._connectionId))
- {
- return false;
- }
-
- if(!IceInternal.Network.addressEquals(_sourceAddr, p._sourceAddr))
- {
- return false;
- }
-
- return _addr.Equals(p._addr);
+ return _delegate.Equals(p._delegate);
}
public override string ToString()
{
- return IceInternal.Network.addrToString(_proxy == null ? _addr : _proxy.getAddress());
+ return _delegate.ToString();
}
public override int GetHashCode()
{
- return _hashCode;
+ return _delegate.GetHashCode();
}
private Instance _instance;
+ private IceInternal.Connector _delegate;
private string _host;
- private IPEndPoint _addr;
- private IceInternal.NetworkProxy _proxy;
- private EndPoint _sourceAddr;
- private int _timeout;
- private string _connectionId;
- private int _hashCode;
}
}
diff --git a/csharp/src/IceSSL/EndpointI.cs b/csharp/src/IceSSL/EndpointI.cs
index 998c604c367..438ece37433 100644
--- a/csharp/src/IceSSL/EndpointI.cs
+++ b/csharp/src/IceSSL/EndpointI.cs
@@ -15,30 +15,17 @@ namespace IceSSL
using System.Net;
using System.Globalization;
- sealed class EndpointI : IceInternal.IPEndpointI, IceInternal.WSEndpointDelegate
+ sealed class EndpointI : IceInternal.EndpointI
{
- internal EndpointI(Instance instance, string ho, int po, EndPoint sourceAddr, int ti, string conId, bool co) :
- base(instance, ho, po, sourceAddr, conId)
+ internal EndpointI(Instance instance, IceInternal.EndpointI del)
{
_instance = instance;
- _timeout = ti;
- _compress = co;
+ _delegate = del;
}
- internal EndpointI(Instance instance) :
- base(instance)
+ public override void streamWriteImpl(Ice.OutputStream os)
{
- _instance = instance;
- _timeout = instance.defaultTimeout();
- _compress = false;
- }
-
- internal EndpointI(Instance instance, Ice.InputStream s) :
- base(instance, s)
- {
- _instance = instance;
- _timeout = s.readInt();
- _compress = s.readBool();
+ _delegate.streamWriteImpl(os);
}
private sealed class InfoI : IceSSL.EndpointInfo
@@ -66,341 +53,245 @@ namespace IceSSL
private EndpointI _endpoint;
}
- //
- // Return the endpoint information.
- //
public override Ice.EndpointInfo getInfo()
{
InfoI info = new InfoI(this);
- fillEndpointInfo(info);
+ info.underlying = _delegate.getInfo();
+ info.compress = info.underlying.compress;
+ info.timeout = info.underlying.timeout;
return info;
}
- private sealed class WSSInfoI : IceSSL.WSSEndpointInfo
+ public override short type()
{
- public WSSInfoI(EndpointI e)
- {
- _endpoint = e;
- }
-
- override public short type()
- {
- return _endpoint.type();
- }
-
- override public bool datagram()
- {
- return _endpoint.datagram();
- }
-
- override public bool secure()
- {
- return _endpoint.secure();
- }
-
- private EndpointI _endpoint;
+ return _delegate.type();
}
- //
- // Return the endpoint information.
- //
- public Ice.EndpointInfo getWSInfo(string resource)
+ public override string protocol()
{
- WSSInfoI info = new WSSInfoI(this);
- fillEndpointInfo(info);
- info.resource = resource;
- return info;
+ return _delegate.protocol();
}
- //
- // Return the timeout for the endpoint in milliseconds. 0 means
- // non-blocking, -1 means no timeout.
- //
public override int timeout()
{
- return _timeout;
+ return _delegate.timeout();
}
- //
- // Return a new endpoint with a different timeout value, provided
- // that timeouts are supported by the endpoint. Otherwise the same
- // endpoint is returned.
- //
public override IceInternal.EndpointI timeout(int timeout)
{
- if(timeout == _timeout)
+ if(timeout == _delegate.timeout())
{
return this;
}
else
{
- return new EndpointI(_instance, host_, port_, sourceAddr_, timeout, connectionId_, _compress);
+ return new EndpointI(_instance, _delegate.timeout(timeout));
}
}
- //
- // Return true if the endpoints support bzip2 compress, or false
- // otherwise.
- //
- public override bool compress()
+ public override string connectionId()
{
- return _compress;
+ return _delegate.connectionId();
}
- //
- // Return a new endpoint with a different compression value,
- // provided that compression is supported by the
- // endpoint. Otherwise the same endpoint is returned.
- //
- public override IceInternal.EndpointI compress(bool compress)
+ public override IceInternal.EndpointI connectionId(string connectionId)
{
- if(compress == _compress)
+ if(connectionId.Equals(_delegate.connectionId()))
{
return this;
}
else
{
- return new EndpointI(_instance, host_, port_, sourceAddr_, _timeout, connectionId_, compress);
+ return new EndpointI(_instance, _delegate.connectionId(connectionId));
}
}
- //
- // Return true if the endpoint is datagram-based.
- //
- public override bool datagram()
+ public override bool compress()
{
- return false;
+ return _delegate.compress();
}
- //
- // Return a server side transceiver for this endpoint, or null if a
- // transceiver can only be created by an acceptor.
- //
- public override IceInternal.Transceiver transceiver()
+ public override IceInternal.EndpointI compress(bool compress)
{
- return null;
+ if(compress == _delegate.compress())
+ {
+ return this;
+ }
+ else
+ {
+ return new EndpointI(_instance, _delegate.compress(compress));
+ }
}
- //
- // Return an acceptor for this endpoint, or null if no acceptor
- // is available.
- //
- public override IceInternal.Acceptor acceptor(string adapterName)
+ public override bool datagram()
{
- return new AcceptorI(this, _instance, adapterName, host_, port_);
+ return _delegate.datagram();
}
- public EndpointI endpoint(AcceptorI acceptor)
+ public override bool secure()
{
- return new EndpointI(_instance, host_, acceptor.effectivePort(), sourceAddr_, _timeout, connectionId_,
- _compress);
+ return _delegate.secure();
}
- public override string options()
+ public override IceInternal.Transceiver transceiver()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
- string s = base.options();
-
- if(_timeout == -1)
- {
- s += " -t infinite";
- }
- else
- {
- s += " -t " + _timeout;
- }
-
- if(_compress)
- {
- s += " -z";
- }
-
- return s;
+ return null;
}
- //
- // Compare endpoints for sorting purposes
- //
- public override int CompareTo(IceInternal.EndpointI obj)
+ private sealed class EndpointI_connectorsI : IceInternal.EndpointI_connectors
{
- if(!(obj is EndpointI))
+ public EndpointI_connectorsI(Instance instance, string host, IceInternal.EndpointI_connectors cb)
{
- return type() < obj.type() ? -1 : 1;
+ _instance = instance;
+ _host = host;
+ _callback = cb;
}
- EndpointI p = (EndpointI)obj;
- if(this == p)
+ public void connectors(List<IceInternal.Connector> connectors)
{
- return 0;
- }
-
- if(_timeout < p._timeout)
- {
- return -1;
- }
- else if(p._timeout < _timeout)
- {
- return 1;
+ List<IceInternal.Connector> l = new List<IceInternal.Connector>();
+ foreach(IceInternal.Connector c in connectors)
+ {
+ l.Add(new ConnectorI(_instance, c, _host));
+ }
+ _callback.connectors(l);
}
- if(!_compress && p._compress)
- {
- return -1;
- }
- else if(!p._compress && _compress)
+ public void exception(Ice.LocalException ex)
{
- return 1;
+ _callback.exception(ex);
}
- return base.CompareTo(p);
+ private Instance _instance;
+ private string _host;
+ private IceInternal.EndpointI_connectors _callback;
}
- public override void streamWriteImpl(Ice.OutputStream s)
+ public override void connectors_async(Ice.EndpointSelectionType selType,
+ IceInternal.EndpointI_connectors callback)
{
- base.streamWriteImpl(s);
- s.writeInt(_timeout);
- s.writeBool(_compress);
+ string host = "";
+ for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p is Ice.IPEndpointInfo)
+ {
+ host = ((Ice.IPEndpointInfo)p).host;
+ break;
+ }
+ }
+ _delegate.connectors_async(selType, new EndpointI_connectorsI(_instance, host, callback));
}
- public override void hashInit(ref int h)
+ public override IceInternal.Acceptor acceptor(string adapterName)
{
- base.hashInit(ref h);
- IceInternal.HashUtil.hashAdd(ref h, _timeout);
- IceInternal.HashUtil.hashAdd(ref h, _compress);
+ return new AcceptorI(this, _instance, _delegate.acceptor(adapterName), adapterName);
}
- public override void fillEndpointInfo(Ice.IPEndpointInfo info)
+ public EndpointI endpoint(IceInternal.EndpointI del)
{
- base.fillEndpointInfo(info);
- info.timeout = _timeout;
- info.compress = _compress;
+ return new EndpointI(_instance, del);
}
- protected override bool checkOption(string option, string argument, string endpoint)
+ public override List<IceInternal.EndpointI> expand()
{
- if(base.checkOption(option, argument, endpoint))
+ List<IceInternal.EndpointI> l = new List<IceInternal.EndpointI>();
+ foreach(IceInternal.EndpointI e in _delegate.expand())
{
- return true;
+ l.Add(e == _delegate ? this : new EndpointI(_instance, e));
}
+ return l;
+ }
- switch(option[1])
- {
- case 't':
+ public override bool equivalent(IceInternal.EndpointI endpoint)
+ {
+ if(!(endpoint is EndpointI))
{
- if(argument == null)
- {
- Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "no argument provided for -t option in endpoint " + endpoint;
- throw e;
- }
-
- if(argument.Equals("infinite"))
- {
- _timeout = -1;
- }
- else
- {
- try
- {
- _timeout = System.Int32.Parse(argument, CultureInfo.InvariantCulture);
- if(_timeout < 1)
- {
- Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
- throw e;
- }
- }
- catch(System.FormatException ex)
- {
- Ice.EndpointParseException e = new Ice.EndpointParseException(ex);
- e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint;
- throw e;
- }
- }
-
- return true;
+ return false;
}
+ EndpointI endpointI = (EndpointI)endpoint;
+ return _delegate.equivalent(endpointI._delegate);
+ }
- case 'z':
- {
- if(argument != null)
- {
- Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint;
- throw e;
- }
+ public override string options()
+ {
+ return _delegate.options();
+ }
- _compress = true;
- return true;
+ //
+ // Compare endpoints for sorting purposes
+ //
+ public override int CompareTo(IceInternal.EndpointI obj)
+ {
+ if(!(obj is EndpointI))
+ {
+ return type() < obj.type() ? -1 : 1;
}
- default:
+ EndpointI p = (EndpointI)obj;
+ if(this == p)
{
- return false;
- }
+ return 0;
}
+
+ return _delegate.CompareTo(p._delegate);
}
- protected override IceInternal.Connector createConnector(EndPoint addr, IceInternal.NetworkProxy proxy)
+ public override int GetHashCode()
{
- return new ConnectorI(_instance, host_, addr, proxy, sourceAddr_, _timeout, connectionId_);
+ return _delegate.GetHashCode();
}
- protected override IceInternal.IPEndpointI createEndpoint(string host, int port, string connectionId)
+ protected override bool checkOption(string option, string argument, string endpoint)
{
- return new EndpointI(_instance, host, port, sourceAddr_, _timeout, connectionId, _compress);
+ return false;
}
private Instance _instance;
- private int _timeout;
- private bool _compress;
+ private IceInternal.EndpointI _delegate;
}
internal sealed class EndpointFactoryI : IceInternal.EndpointFactory
{
- internal EndpointFactoryI(Instance instance)
+ internal EndpointFactoryI(Instance instance, IceInternal.EndpointFactory del)
{
_instance = instance;
+ _delegate = del;
}
public short type()
{
- return _instance.type();
+ return _delegate.type();
}
public string protocol()
{
- return _instance.protocol();
+ return _delegate.protocol();
}
public IceInternal.EndpointI create(List<string> args, bool oaEndpoint)
{
- IceInternal.IPEndpointI endpt = new EndpointI(_instance);
- endpt.initWithOptions(args, oaEndpoint);
- return endpt;
+ return new EndpointI(_instance, _delegate.create(args, oaEndpoint));
}
public IceInternal.EndpointI read(Ice.InputStream s)
{
- return new EndpointI(_instance, s);
+ return new EndpointI(_instance, _delegate.read(s));
}
public void destroy()
{
+ _delegate.destroy();
_instance = null;
}
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst,
+ IceInternal.EndpointFactory del)
{
- return new EndpointFactoryI(new Instance(_instance.engine(), instance.type(), instance.protocol()));
+ Instance instance = new Instance(_instance.engine(), inst.type(), inst.protocol());
+ return new EndpointFactoryI(instance, del != null ? del : _delegate.clone(instance, null));
}
private Instance _instance;
+ private IceInternal.EndpointFactory _delegate;
}
}
diff --git a/csharp/src/IceSSL/Instance.cs b/csharp/src/IceSSL/Instance.cs
index 6b08ecdbd71..b115e682db8 100644
--- a/csharp/src/IceSSL/Instance.cs
+++ b/csharp/src/IceSSL/Instance.cs
@@ -68,9 +68,9 @@ namespace IceSSL
_engine.traceStream(stream, connInfo);
}
- internal void verifyPeer(NativeConnectionInfo info, System.Net.Sockets.Socket fd, string address)
+ internal void verifyPeer(string address, NativeConnectionInfo info, string desc)
{
- _engine.verifyPeer(info, fd, address);
+ _engine.verifyPeer(address, info, desc);
}
private SSLEngine _engine;
diff --git a/csharp/src/IceSSL/PluginI.cs b/csharp/src/IceSSL/PluginI.cs
index a7470596b74..9c0e3825a47 100644
--- a/csharp/src/IceSSL/PluginI.cs
+++ b/csharp/src/IceSSL/PluginI.cs
@@ -41,12 +41,14 @@ namespace IceSSL
_engine = new SSLEngine(facade);
//
- // Register the endpoint factory. We have to do this now, rather than
- // in initialize, because the communicator may need to interpret
- // proxies before the plug-in is fully initialized.
+ // SSL based on TCP
//
- EndpointFactoryI factory = new EndpointFactoryI(new Instance(_engine, IceSSL.EndpointType.value, "ssl"));
- facade.addEndpointFactory(factory);
+ IceInternal.EndpointFactory tcp = facade.getEndpointFactory(Ice.TCPEndpointType.value);
+ if(tcp != null)
+ {
+ Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl");
+ facade.addEndpointFactory(new EndpointFactoryI(instance, tcp.clone(instance, null)));
+ }
}
public override void initialize()
diff --git a/csharp/src/IceSSL/SSLEngine.cs b/csharp/src/IceSSL/SSLEngine.cs
index bd8f527b8e4..6845b3143fe 100644
--- a/csharp/src/IceSSL/SSLEngine.cs
+++ b/csharp/src/IceSSL/SSLEngine.cs
@@ -534,7 +534,7 @@ namespace IceSSL
_logger.trace(_securityTraceCategory, s.ToString());
}
- internal void verifyPeer(NativeConnectionInfo info, System.Net.Sockets.Socket fd, string address)
+ internal void verifyPeer(string address, NativeConnectionInfo info, string desc)
{
//
// For an outgoing connection, we compare the proxy address (if any) against
@@ -732,8 +732,7 @@ namespace IceSSL
{
string msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected:\n" +
"length of peer's certificate chain (" + info.nativeCerts.Length + ") exceeds maximum of " +
- _verifyDepthMax + "\n" +
- IceInternal.Network.fdToString(fd);
+ _verifyDepthMax + "\n" + desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
@@ -743,10 +742,10 @@ namespace IceSSL
throw ex;
}
- if(!_trustManager.verify(info))
+ if(!_trustManager.verify(info, desc))
{
string msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by trust manager\n" +
- IceInternal.Network.fdToString(fd);
+ desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
@@ -760,7 +759,7 @@ namespace IceSSL
if(_verifier != null && !_verifier.verify(info))
{
string msg = (info.incoming ? "incoming" : "outgoing") +
- " connection rejected by certificate verifier\n" + IceInternal.Network.fdToString(fd);
+ " connection rejected by certificate verifier\n" + desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
diff --git a/csharp/src/IceSSL/TransceiverI.cs b/csharp/src/IceSSL/TransceiverI.cs
index 171211fb3b5..5ec9afccf8a 100644
--- a/csharp/src/IceSSL/TransceiverI.cs
+++ b/csharp/src/IceSSL/TransceiverI.cs
@@ -20,47 +20,60 @@ namespace IceSSL
using System.Security.Cryptography.X509Certificates;
using System.Text;
- sealed class TransceiverI : IceInternal.Transceiver, IceInternal.WSTransceiverDelegate
+ sealed class TransceiverI : IceInternal.Transceiver
{
public Socket fd()
{
- return _stream.fd();
+ return _delegate.fd();
}
public int initialize(IceInternal.Buffer readBuffer, IceInternal.Buffer writeBuffer, ref bool hasMoreData)
{
- int status = _stream.connect(readBuffer, writeBuffer, ref hasMoreData);
- if(status != IceInternal.SocketOperation.None)
+ if(!_isConnected)
{
- return status;
+ int status = _delegate.initialize(readBuffer, writeBuffer, ref hasMoreData);
+ if(status != IceInternal.SocketOperation.None)
+ {
+ return status;
+ }
+ _isConnected = true;
}
- _stream.setBlock(true); // SSL requires a blocking socket
+ IceInternal.Network.setBlock(fd(), true); // SSL requires a blocking socket
+
+ //
+ // For timeouts to work properly, we need to receive/send
+ // the data in several chunks. Otherwise, we would only be
+ // notified when all the data is received/written. The
+ // connection timeout could easily be triggered when
+ // receiging/sending large messages.
+ //
+ _maxSendPacketSize = System.Math.Max(512, IceInternal.Network.getSendBufferSize(fd()));
+ _maxRecvPacketSize = System.Math.Max(512, IceInternal.Network.getRecvBufferSize(fd()));
if(_sslStream == null)
{
- NetworkStream ns = new NetworkStream(_stream.fd(), false);
- _sslStream = new SslStream(ns, false, new RemoteCertificateValidationCallback(validationCallback),
- new LocalCertificateSelectionCallback(selectCertificate));
+ _sslStream = new SslStream(new NetworkStream(_delegate.fd(), false),
+ false,
+ new RemoteCertificateValidationCallback(validationCallback),
+ new LocalCertificateSelectionCallback(selectCertificate));
return IceInternal.SocketOperation.Connect;
}
Debug.Assert(_sslStream.IsAuthenticated);
_authenticated = true;
- _instance.verifyPeer((NativeConnectionInfo)getInfo(), _stream.fd(), _host);
+ _instance.verifyPeer(_host, (NativeConnectionInfo)getInfo(), ToString());
if(_instance.securityTraceLevel() >= 1)
{
- _instance.traceStream(_sslStream, _stream.ToString());
+ _instance.traceStream(_sslStream, ToString());
}
return IceInternal.SocketOperation.None;
}
public int closing(bool initiator, Ice.LocalException ex)
{
- // If we are initiating the connection closure, wait for the peer
- // to close the TCP/IP connection. Otherwise, close immediately.
- return initiator ? IceInternal.SocketOperation.Read : IceInternal.SocketOperation.None;
+ return _delegate.closing(initiator, ex);
}
public void close()
@@ -71,7 +84,7 @@ namespace IceSSL
_sslStream = null;
}
- _stream.close();
+ _delegate.close();
}
public IceInternal.EndpointI bind()
@@ -82,7 +95,7 @@ namespace IceSSL
public void destroy()
{
- _stream.destroy();
+ _delegate.destroy();
}
public int write(IceInternal.Buffer buf)
@@ -103,14 +116,14 @@ namespace IceSSL
public bool startRead(IceInternal.Buffer buf, IceInternal.AsyncCallback callback, object state)
{
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- return _stream.startRead(buf, callback, state);
+ return _delegate.startRead(buf, callback, state);
}
Debug.Assert(_sslStream != null && _sslStream.IsAuthenticated);
- int packetSz = _stream.getRecvPacketSize(buf.b.remaining());
+ int packetSz = getRecvPacketSize(buf.b.remaining());
try
{
_readCallback = callback;
@@ -141,9 +154,9 @@ namespace IceSSL
public void finishRead(IceInternal.Buffer buf)
{
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- _stream.finishRead(buf);
+ _delegate.finishRead(buf);
return;
}
else if(_sslStream == null) // Transceiver was closed
@@ -191,29 +204,28 @@ namespace IceSSL
}
}
- public bool startWrite(IceInternal.Buffer buf, IceInternal.AsyncCallback callback, object state,
- out bool completed)
+ public bool startWrite(IceInternal.Buffer buf, IceInternal.AsyncCallback cb, object state, out bool completed)
{
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- return _stream.startWrite(buf, callback, state, out completed);
+ return _delegate.startWrite(buf, cb, state, out completed);
}
Debug.Assert(_sslStream != null);
if(!_authenticated)
{
completed = false;
- return startAuthenticate(callback, state);
+ return startAuthenticate(cb, state);
}
//
// We limit the packet size for beingWrite to ensure connection timeouts are based
// on a fixed packet size.
//
- int packetSize = _stream.getSendPacketSize(buf.b.remaining());
+ int packetSize = getSendPacketSize(buf.b.remaining());
try
{
- _writeCallback = callback;
+ _writeCallback = cb;
_writeResult = _sslStream.BeginWrite(buf.b.rawBytes(), buf.b.position(), packetSize, writeCompleted,
state);
completed = packetSize == buf.b.remaining();
@@ -243,14 +255,14 @@ namespace IceSSL
public void finishWrite(IceInternal.Buffer buf)
{
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- _stream.finishWrite(buf);
+ _delegate.finishWrite(buf);
return;
}
else if(_sslStream == null) // Transceiver was closed
{
- if(_stream.getSendPacketSize(buf.b.remaining()) == buf.b.remaining()) // Sent last packet
+ if(getSendPacketSize(buf.b.remaining()) == buf.b.remaining()) // Sent last packet
{
buf.b.position(buf.b.limit()); // Assume all the data was sent for at-most-once semantics.
}
@@ -264,7 +276,7 @@ namespace IceSSL
}
Debug.Assert(_writeResult != null);
- int sent = _stream.getSendPacketSize(buf.b.remaining());
+ int sent = getSendPacketSize(buf.b.remaining());
try
{
_sslStream.EndWrite(_writeResult);
@@ -295,50 +307,72 @@ namespace IceSSL
public string protocol()
{
- return _instance.protocol();
+ return _delegate.protocol();
}
public Ice.ConnectionInfo getInfo()
{
NativeConnectionInfo info = new NativeConnectionInfo();
- info.nativeCerts = fillConnectionInfo(info);
- return info;
- }
+ info.underlying = _delegate.getInfo();
+ info.incoming = _incoming;
+ info.adapterName = _adapterName;
+ if(_sslStream != null)
+ {
+ info.cipher = _sslStream.CipherAlgorithm.ToString();
+ if(_chain.ChainElements != null && _chain.ChainElements.Count > 0)
+ {
+ info.nativeCerts = new X509Certificate2[_chain.ChainElements.Count];
+ for(int i = 0; i < _chain.ChainElements.Count; ++i)
+ {
+ info.nativeCerts[i] = _chain.ChainElements[i].Certificate;
+ }
+ }
- public Ice.ConnectionInfo getWSInfo(Dictionary<string, string> headers)
- {
- WSSNativeConnectionInfo info = new WSSNativeConnectionInfo();
- info.nativeCerts = fillConnectionInfo(info);
- info.headers = headers;
+ List<string> certs = new List<string>();
+ if(info.nativeCerts != null)
+ {
+ foreach(X509Certificate2 cert in info.nativeCerts)
+ {
+ StringBuilder s = new StringBuilder();
+ s.Append("-----BEGIN CERTIFICATE-----\n");
+ s.Append(Convert.ToBase64String(cert.Export(X509ContentType.Cert)));
+ s.Append("\n-----END CERTIFICATE-----");
+ certs.Add(s.ToString());
+ }
+ }
+ info.certs = certs.ToArray();
+ info.verified = _verified;
+ }
return info;
}
public void checkSendSize(IceInternal.Buffer buf)
{
+ _delegate.checkSendSize(buf);
}
public void setBufferSize(int rcvSize, int sndSize)
{
- _stream.setBufferSize(rcvSize, sndSize);
+ _delegate.setBufferSize(rcvSize, sndSize);
}
public override string ToString()
{
- return _stream.ToString();
+ return _delegate.ToString();
}
public string toDetailedString()
{
- return ToString();
+ return _delegate.toDetailedString();
}
//
// Only for use by ConnectorI, AcceptorI.
//
- internal TransceiverI(Instance instance, IceInternal.StreamSocket stream, string hostOrAdapterName, bool incoming)
+ internal TransceiverI(Instance instance, IceInternal.Transceiver del, string hostOrAdapterName, bool incoming)
{
_instance = instance;
- _stream = stream;
+ _delegate = del;
_incoming = incoming;
if(_incoming)
{
@@ -348,6 +382,7 @@ namespace IceSSL
{
_host = hostOrAdapterName;
}
+
_sslStream = null;
_verifyPeer = _instance.properties().getPropertyAsIntWithDefault("IceSSL.VerifyPeer", 2);
@@ -373,55 +408,6 @@ namespace IceSSL
}
}
- private X509Certificate2[] fillConnectionInfo(ConnectionInfo info)
- {
- X509Certificate2[] nativeCerts = null;
- if(_stream.fd() != null)
- {
- IPEndPoint localEndpoint = (IPEndPoint)IceInternal.Network.getLocalAddress(_stream.fd());
- info.localAddress = localEndpoint.Address.ToString();
- info.localPort = localEndpoint.Port;
- IPEndPoint remoteEndpoint = (IPEndPoint)IceInternal.Network.getRemoteAddress(_stream.fd());
- if(remoteEndpoint != null)
- {
- info.remoteAddress = remoteEndpoint.Address.ToString();
- info.remotePort = remoteEndpoint.Port;
- }
- info.rcvSize = IceInternal.Network.getRecvBufferSize(_stream.fd());
- info.sndSize = IceInternal.Network.getSendBufferSize(_stream.fd());
- }
- if(_sslStream != null)
- {
- info.cipher = _sslStream.CipherAlgorithm.ToString();
- if(_chain.ChainElements != null && _chain.ChainElements.Count > 0)
- {
- nativeCerts = new X509Certificate2[_chain.ChainElements.Count];
- for(int i = 0; i < _chain.ChainElements.Count; ++i)
- {
- nativeCerts[i] = _chain.ChainElements[i].Certificate;
- }
- }
-
- List<string> certs = new List<string>();
- if(nativeCerts != null)
- {
- foreach(X509Certificate2 cert in nativeCerts)
- {
- StringBuilder s = new StringBuilder();
- s.Append("-----BEGIN CERTIFICATE-----\n");
- s.Append(Convert.ToBase64String(cert.Export(X509ContentType.Cert)));
- s.Append("\n-----END CERTIFICATE-----");
- certs.Add(s.ToString());
- }
- }
- info.certs = certs.ToArray();
- info.verified = _verified;
- }
- info.adapterName = _adapterName;
- info.incoming = _incoming;
- return nativeCerts;
- }
-
private bool startAuthenticate(IceInternal.AsyncCallback callback, object state)
{
try
@@ -527,12 +513,8 @@ namespace IceSSL
}
}
- private X509Certificate selectCertificate(
- object sender,
- string targetHost,
- X509CertificateCollection certs,
- X509Certificate remoteCertificate,
- string[] acceptableIssuers)
+ private X509Certificate selectCertificate(object sender, string targetHost, X509CertificateCollection certs,
+ X509Certificate remoteCertificate, string[] acceptableIssuers)
{
if(certs == null || certs.Count == 0)
{
@@ -758,13 +740,24 @@ namespace IceSSL
}
}
+ private int getSendPacketSize(int length)
+ {
+ return _maxSendPacketSize > 0 ? System.Math.Min(length, _maxSendPacketSize) : length;
+ }
+
+ public int getRecvPacketSize(int length)
+ {
+ return _maxRecvPacketSize > 0 ? System.Math.Min(length, _maxRecvPacketSize) : length;
+ }
+
private Instance _instance;
- private IceInternal.StreamSocket _stream;
+ private IceInternal.Transceiver _delegate;
private string _host = "";
private string _adapterName = "";
private bool _incoming;
private SslStream _sslStream;
private int _verifyPeer;
+ private bool _isConnected;
private bool _authenticated;
private IAsyncResult _writeResult;
private IAsyncResult _readResult;
@@ -772,5 +765,7 @@ namespace IceSSL
private IceInternal.AsyncCallback _writeCallback;
private X509Chain _chain;
private bool _verified;
+ private int _maxSendPacketSize;
+ private int _maxRecvPacketSize;
}
}
diff --git a/csharp/src/IceSSL/TrustManager.cs b/csharp/src/IceSSL/TrustManager.cs
index b9cba557a25..2813ecdc942 100644
--- a/csharp/src/IceSSL/TrustManager.cs
+++ b/csharp/src/IceSSL/TrustManager.cs
@@ -58,7 +58,7 @@ namespace IceSSL
}
}
- internal bool verify(NativeConnectionInfo info)
+ internal bool verify(NativeConnectionInfo info, string desc)
{
List<List<List<RFC2253.RDNPair>>> reject = new List<List<List<RFC2253.RDNPair>>>(),
accept = new List<List<List<RFC2253.RDNPair>>>();
@@ -143,17 +143,12 @@ namespace IceSSL
if(info.incoming)
{
communicator_.getLogger().trace("Security", "trust manager evaluating client:\n" +
- "subject = " + subjectName + "\n" +
- "adapter = " + info.adapterName + "\n" +
- "local addr = " + info.localAddress + ":" + info.localPort + "\n" +
- "remote addr = " + info.remoteAddress + ":" + info.remotePort);
+ "subject = " + subjectName + "\n" + "adapter = " + info.adapterName + "\n" + desc);
}
else
{
communicator_.getLogger().trace("Security", "trust manager evaluating server:\n" +
- "subject = " + subjectName + "\n" +
- "local addr = " + info.localAddress + ":" + info.localPort + "\n" +
- "remote addr = " + info.remoteAddress + ":" + info.remotePort);
+ "subject = " + subjectName + "\n" + desc);
}
}
diff --git a/csharp/src/IceSSL/Util.cs b/csharp/src/IceSSL/Util.cs
index 7b64a30befc..1b617dff0a0 100644
--- a/csharp/src/IceSSL/Util.cs
+++ b/csharp/src/IceSSL/Util.cs
@@ -28,20 +28,6 @@ namespace IceSSL
public System.Security.Cryptography.X509Certificates.X509Certificate2[] nativeCerts;
}
- /// <summary>
- /// This class provides information about a connection to applications
- /// that require information about a peer.
- /// </summary>
- public sealed class WSSNativeConnectionInfo : WSSConnectionInfo
- {
- /// <summary>
- /// The certificate chain. This may be null if the peer did not
- /// supply a certificate. The peer's certificate (if any) is the
- /// first one in the chain.
- /// </summary>
- public System.Security.Cryptography.X509Certificates.X509Certificate2[] nativeCerts;
- }
-
public sealed class Util
{
public static X509Certificate2 createCertificate(string certPEM)
diff --git a/csharp/test/Ice/background/EndpointFactory.cs b/csharp/test/Ice/background/EndpointFactory.cs
index 9b22a07a0f1..3bcd027340c 100644
--- a/csharp/test/Ice/background/EndpointFactory.cs
+++ b/csharp/test/Ice/background/EndpointFactory.cs
@@ -47,7 +47,7 @@ internal class EndpointFactory : IceInternal.EndpointFactory
{
}
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance, IceInternal.EndpointFactory del)
{
return this;
}
diff --git a/csharp/test/Ice/background/EndpointI.cs b/csharp/test/Ice/background/EndpointI.cs
index 1993bd7e668..6c7e97d3991 100644
--- a/csharp/test/Ice/background/EndpointI.cs
+++ b/csharp/test/Ice/background/EndpointI.cs
@@ -30,12 +30,10 @@ internal class EndpointI : IceInternal.EndpointI
return _endpoint.getInfo();
}
- public override void streamWrite(Ice.OutputStream s)
+ public override void streamWriteImpl(Ice.OutputStream s)
{
- s.startEncapsulation();
s.writeShort(_endpoint.type());
_endpoint.streamWrite(s);
- s.endEncapsulation();
}
public override short type()
diff --git a/csharp/test/Ice/info/AllTests.cs b/csharp/test/Ice/info/AllTests.cs
index 1c1b34e30cb..138bc702d1a 100644
--- a/csharp/test/Ice/info/AllTests.cs
+++ b/csharp/test/Ice/info/AllTests.cs
@@ -13,6 +13,30 @@ using Test;
public class AllTests : TestCommon.TestApp
{
+ private static Ice.TCPEndpointInfo getTCPEndpointInfo(Ice.EndpointInfo info)
+ {
+ for(; info != null; info = info.underlying)
+ {
+ if(info is Ice.TCPEndpointInfo)
+ {
+ return info as Ice.TCPEndpointInfo;
+ }
+ }
+ return null;
+ }
+
+ private static Ice.TCPConnectionInfo getTCPConnectionInfo(Ice.ConnectionInfo info)
+ {
+ for(; info != null; info = info.underlying)
+ {
+ if(info is Ice.TCPConnectionInfo)
+ {
+ return info as Ice.TCPConnectionInfo;
+ }
+ }
+ return null;
+ }
+
public static void allTests(Ice.Communicator communicator)
{
Write("testing proxy endpoint information... ");
@@ -25,24 +49,23 @@ public class AllTests : TestCommon.TestApp
Ice.Endpoint[] endps = p1.ice_getEndpoints();
-
- Ice.IPEndpointInfo ipEndpoint = (Ice.IPEndpointInfo)endps[0].getInfo();
- test(ipEndpoint.host.Equals("tcphost"));
- test(ipEndpoint.port == 10000);
- test(ipEndpoint.sourceAddress.Equals("10.10.10.10"));
- test(ipEndpoint.timeout == 1200);
- test(ipEndpoint.compress);
- test(!ipEndpoint.datagram());
-
-
- test(ipEndpoint.type() == Ice.TCPEndpointType.value && !ipEndpoint.secure() ||
- ipEndpoint.type() == IceSSL.EndpointType.value && ipEndpoint.secure() ||
- ipEndpoint.type() == Ice.WSEndpointType.value && !ipEndpoint.secure() ||
- ipEndpoint.type() == Ice.WSSEndpointType.value && ipEndpoint.secure());
- test(ipEndpoint.type() == Ice.TCPEndpointType.value && ipEndpoint is Ice.TCPEndpointInfo ||
- ipEndpoint.type() == IceSSL.EndpointType.value && ipEndpoint is IceSSL.EndpointInfo ||
- ipEndpoint.type() == Ice.WSEndpointType.value && ipEndpoint is Ice.WSEndpointInfo ||
- ipEndpoint.type() == Ice.WSSEndpointType.value && ipEndpoint is IceSSL.WSSEndpointInfo);
+ Ice.EndpointInfo info = endps[0].getInfo();
+ Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(info);
+ test(tcpEndpoint.host.Equals("tcphost"));
+ test(tcpEndpoint.port == 10000);
+ test(tcpEndpoint.sourceAddress.Equals("10.10.10.10"));
+ test(tcpEndpoint.timeout == 1200);
+ test(tcpEndpoint.compress);
+ test(!tcpEndpoint.datagram());
+
+ test(tcpEndpoint.type() == Ice.TCPEndpointType.value && !tcpEndpoint.secure() ||
+ tcpEndpoint.type() == Ice.SSLEndpointType.value && tcpEndpoint.secure() ||
+ tcpEndpoint.type() == Ice.WSEndpointType.value && !tcpEndpoint.secure() ||
+ tcpEndpoint.type() == Ice.WSSEndpointType.value && tcpEndpoint.secure());
+ test(tcpEndpoint.type() == Ice.TCPEndpointType.value && info is Ice.TCPEndpointInfo ||
+ tcpEndpoint.type() == Ice.SSLEndpointType.value && info is IceSSL.EndpointInfo ||
+ tcpEndpoint.type() == Ice.WSEndpointType.value && info is Ice.WSEndpointInfo ||
+ tcpEndpoint.type() == Ice.WSSEndpointType.value && info is Ice.WSEndpointInfo);
Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endps[1].getInfo();
test(udpEndpoint.host.Equals("udphost"));
@@ -75,13 +98,13 @@ public class AllTests : TestCommon.TestApp
Ice.Endpoint[] publishedEndpoints = adapter.getPublishedEndpoints();
test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints));
- Ice.IPEndpointInfo ipEndpoint = (Ice.IPEndpointInfo)endpoints[0].getInfo();
- test(ipEndpoint.type() == Ice.TCPEndpointType.value || ipEndpoint.type() == IceSSL.EndpointType.value ||
- ipEndpoint.type() == Ice.WSEndpointType.value || ipEndpoint.type() == Ice.WSSEndpointType.value);
+ Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo());
+ test(tcpEndpoint.type() == Ice.TCPEndpointType.value || tcpEndpoint.type() == Ice.SSLEndpointType.value ||
+ tcpEndpoint.type() == Ice.WSEndpointType.value || tcpEndpoint.type() == Ice.WSSEndpointType.value);
- test(ipEndpoint.host.Equals(defaultHost));
- test(ipEndpoint.port > 0);
- test(ipEndpoint.timeout == 15000);
+ test(tcpEndpoint.host.Equals(defaultHost));
+ test(tcpEndpoint.port > 0);
+ test(tcpEndpoint.timeout == 15000);
Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endpoints[1].getInfo();
test(udpEndpoint.host.Equals(defaultHost));
@@ -101,13 +124,13 @@ public class AllTests : TestCommon.TestApp
foreach(Ice.Endpoint endpoint in endpoints)
{
- ipEndpoint = (Ice.IPEndpointInfo)endpoint.getInfo();
- test(ipEndpoint.port == 12020);
+ tcpEndpoint = getTCPEndpointInfo(endpoint.getInfo());
+ test(tcpEndpoint.port == 12020);
}
- ipEndpoint = (Ice.IPEndpointInfo)publishedEndpoints[0].getInfo();
- test(ipEndpoint.host.Equals("127.0.0.1"));
- test(ipEndpoint.port == 12020);
+ tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo());
+ test(tcpEndpoint.host.Equals("127.0.0.1"));
+ test(tcpEndpoint.port == 12020);
adapter.destroy();
}
@@ -120,13 +143,13 @@ public class AllTests : TestCommon.TestApp
Flush();
{
Ice.EndpointInfo info = @base.ice_getConnection().getEndpoint().getInfo();
- Ice.IPEndpointInfo ipinfo = (Ice.IPEndpointInfo)info;
- test(ipinfo.port == 12010);
- test(!ipinfo.compress);
- test(ipinfo.host.Equals(defaultHost));
+ Ice.TCPEndpointInfo tcpinfo = getTCPEndpointInfo(info);
+ test(tcpinfo.port == 12010);
+ test(!tcpinfo.compress);
+ test(tcpinfo.host.Equals(defaultHost));
Dictionary<string, string> ctx = testIntf.getEndpointInfoAsContext();
- test(ctx["host"].Equals(ipinfo.host));
+ test(ctx["host"].Equals(tcpinfo.host));
test(ctx["compress"].Equals("false"));
int port = System.Int32.Parse(ctx["port"]);
test(port > 0);
@@ -144,38 +167,31 @@ public class AllTests : TestCommon.TestApp
Ice.Connection connection = @base.ice_getConnection();
connection.setBufferSize(1024, 2048);
- Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)connection.getInfo();
+ Ice.ConnectionInfo info = connection.getInfo();
+ Ice.TCPConnectionInfo ipInfo = getTCPConnectionInfo(info);
test(!info.incoming);
test(info.adapterName.Length == 0);
- test(info.remotePort == 12010);
- test(info.localPort > 0);
+ test(ipInfo.remotePort == 12010);
+ test(ipInfo.localPort > 0);
if(defaultHost.Equals("127.0.0.1"))
{
- test(info.localAddress.Equals(defaultHost));
- test(info.remoteAddress.Equals(defaultHost));
+ test(ipInfo.localAddress.Equals(defaultHost));
+ test(ipInfo.remoteAddress.Equals(defaultHost));
}
- test(info.rcvSize >= 1024);
- test(info.sndSize >= 2048);
+ test(ipInfo.rcvSize >= 1024);
+ test(ipInfo.sndSize >= 2048);
Dictionary<string, string> ctx = testIntf.getConnectionInfoAsContext();
test(ctx["incoming"].Equals("true"));
test(ctx["adapterName"].Equals("TestAdapter"));
- test(ctx["remoteAddress"].Equals(info.localAddress));
- test(ctx["localAddress"].Equals(info.remoteAddress));
- test(ctx["remotePort"].Equals(info.localPort.ToString()));
- test(ctx["localPort"].Equals(info.remotePort.ToString()));
+ test(ctx["remoteAddress"].Equals(ipInfo.localAddress));
+ test(ctx["localAddress"].Equals(ipInfo.remoteAddress));
+ test(ctx["remotePort"].Equals(ipInfo.localPort.ToString()));
+ test(ctx["localPort"].Equals(ipInfo.remotePort.ToString()));
if(@base.ice_getConnection().type().Equals("ws") || @base.ice_getConnection().type().Equals("wss"))
{
- Dictionary<string, string> headers;
- if(info is Ice.WSConnectionInfo)
- {
- headers = ((Ice.WSConnectionInfo)info).headers;
- }
- else
- {
- headers = ((IceSSL.WSSConnectionInfo)info).headers;
- }
+ Dictionary<string, string> headers = ((Ice.WSConnectionInfo)info).headers;
test(headers["Upgrade"].Equals("websocket"));
test(headers["Connection"].Equals("Upgrade"));
test(headers["Sec-WebSocket-Protocol"].Equals("ice.zeroc.com"));
@@ -191,19 +207,19 @@ public class AllTests : TestCommon.TestApp
connection = @base.ice_datagram().ice_getConnection();
connection.setBufferSize(2048, 1024);
- info = (Ice.IPConnectionInfo)connection.getInfo();
- test(!info.incoming);
- test(info.adapterName.Length == 0);
- test(info.localPort > 0);
- test(info.remotePort == 12010);
+ Ice.UDPConnectionInfo udpInfo = (Ice.UDPConnectionInfo)connection.getInfo();
+ test(!udpInfo.incoming);
+ test(udpInfo.adapterName.Length == 0);
+ test(udpInfo.localPort > 0);
+ test(udpInfo.remotePort == 12010);
if(defaultHost.Equals("127.0.0.1"))
{
- test(info.remoteAddress.Equals(defaultHost));
- test(info.localAddress.Equals(defaultHost));
+ test(udpInfo.remoteAddress.Equals(defaultHost));
+ test(udpInfo.localAddress.Equals(defaultHost));
}
- test(info.rcvSize >= 2048);
- test(info.sndSize >= 1024);
+ test(udpInfo.rcvSize >= 2048);
+ test(udpInfo.sndSize >= 1024);
}
WriteLine("ok");
diff --git a/csharp/test/Ice/info/TestI.cs b/csharp/test/Ice/info/TestI.cs
index 7198a50d8b6..7463060adc2 100644
--- a/csharp/test/Ice/info/TestI.cs
+++ b/csharp/test/Ice/info/TestI.cs
@@ -12,6 +12,30 @@ using System.Collections.Generic;
public class TestI : TestIntfDisp_
{
+ private static Ice.IPEndpointInfo getIPEndpointInfo(Ice.EndpointInfo info)
+ {
+ for(; info != null; info = info.underlying)
+ {
+ if(info is Ice.IPEndpointInfo)
+ {
+ return info as Ice.IPEndpointInfo;
+ }
+ }
+ return null;
+ }
+
+ private static Ice.IPConnectionInfo getIPConnectionInfo(Ice.ConnectionInfo info)
+ {
+ for(; info != null; info = info.underlying)
+ {
+ if(info is Ice.IPConnectionInfo)
+ {
+ return info as Ice.IPConnectionInfo;
+ }
+ }
+ return null;
+ }
+
override public void shutdown(Ice.Current current)
{
current.adapter.getCommunicator().shutdown();
@@ -27,7 +51,7 @@ public class TestI : TestIntfDisp_
ctx["secure"] = info.datagram() ? "true" : "false";
ctx["type"] = info.type().ToString();
- Ice.IPEndpointInfo ipinfo = (Ice.IPEndpointInfo)info;
+ Ice.IPEndpointInfo ipinfo = getIPEndpointInfo(info);
ctx["host"] = ipinfo.host;
ctx["port"] = ipinfo.port.ToString();
@@ -48,7 +72,7 @@ public class TestI : TestIntfDisp_
ctx["adapterName"] = info.adapterName;
ctx["incoming"] = info.incoming ? "true" : "false";
- Ice.IPConnectionInfo ipinfo = (Ice.IPConnectionInfo)info;
+ Ice.IPConnectionInfo ipinfo = getIPConnectionInfo(info);
ctx["localAddress"] = ipinfo.localAddress;
ctx["localPort"] = ipinfo.localPort.ToString();
ctx["remoteAddress"] = ipinfo.remoteAddress;
@@ -63,15 +87,6 @@ public class TestI : TestIntfDisp_
}
}
- if(info is IceSSL.WSSConnectionInfo)
- {
- IceSSL.WSSConnectionInfo wssinfo = (IceSSL.WSSConnectionInfo)info;
- foreach(KeyValuePair<string, string> e in wssinfo.headers)
- {
- ctx["ws." + e.Key] = e.Value;
- }
- }
-
return ctx;
}
}
diff --git a/csharp/test/Ice/metrics/AllTests.cs b/csharp/test/Ice/metrics/AllTests.cs
index edd3e6a09d2..bb3cb69fd5d 100644
--- a/csharp/test/Ice/metrics/AllTests.cs
+++ b/csharp/test/Ice/metrics/AllTests.cs
@@ -465,6 +465,18 @@ public class AllTests : TestCommon.TestApp
WriteLine("ok");
+
+ string endpoint = communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp") +
+ " -h 127.0.0.1 -p 12010";
+ string type = "";
+ string isSecure = "";
+ if(!collocated)
+ {
+ Ice.EndpointInfo endpointInfo = metrics.ice_getConnection().getEndpoint().getInfo();
+ type = endpointInfo.type().ToString();
+ isSecure = endpointInfo.secure() ? "True": "False";
+ }
+
Dictionary<string, IceMX.Metrics> map;
if(!collocated)
@@ -600,11 +612,11 @@ public class AllTests : TestCommon.TestApp
testAttribute(clientMetrics, clientProps, update, "Connection", "parent", "Communicator");
//testAttribute(clientMetrics, clientProps, update, "Connection", "id", "");
testAttribute(clientMetrics, clientProps, update, "Connection", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 500");
+ endpoint + " -t 500");
- testAttribute(clientMetrics, clientProps, update, "Connection", "endpointType", "1");
+ testAttribute(clientMetrics, clientProps, update, "Connection", "endpointType", type);
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsDatagram", "False");
- testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsSecure", "False");
+ testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsSecure", isSecure);
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointTimeout", "500");
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointCompress", "False");
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointHost", "127.0.0.1");
@@ -665,12 +677,12 @@ public class AllTests : TestCommon.TestApp
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "parent", "Communicator", c);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "id", "127.0.0.1:12010", c);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 60000", c);
+ endpoint + " -t 60000", c);
- testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointType", "1", c);
+ testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointType", type, c);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "False",
c);
- testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", "False",
+ testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", isSecure,
c);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "60000", c);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointCompress", "False",
@@ -693,7 +705,7 @@ public class AllTests : TestCommon.TestApp
test(clientMetrics.getMetricsView("View", out timestamp)["EndpointLookup"].Length == 1);
m1 = clientMetrics.getMetricsView("View", out timestamp)["EndpointLookup"][0];
- test(m1.current <= 1 && m1.total == 1 && m1.id.Equals("tcp -h localhost -p 12010 -t infinite"));
+ test(m1.current <= 1 && m1.total == 1 && m1.id.Equals(prx.ice_getConnection().getEndpoint().ToString()));
prx.ice_getConnection().close(false);
@@ -728,13 +740,13 @@ public class AllTests : TestCommon.TestApp
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "parent", "Communicator", c);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id",
- "tcp -h localhost -p 12010 -t infinite", c);
+ prx.ice_getConnection().getEndpoint().ToString(), c);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint",
- "tcp -h localhost -p 12010 -t infinite", c);
+ prx.ice_getConnection().getEndpoint().ToString(), c);
- testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", "1", c);
+ testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", type, c);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsDatagram", "False", c);
- testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsSecure", "False", c);
+ testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsSecure", isSecure, c);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointTimeout", "-1", c);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointCompress", "False", c);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointHost", "localhost", c);
@@ -828,12 +840,12 @@ public class AllTests : TestCommon.TestApp
if(!collocated)
{
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 60000", op);
+ endpoint + " -t 60000", op);
//testAttribute(serverMetrics, serverProps, update, "Dispatch", "connection", "", op);
- testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointType", "1", op);
+ testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointType", type, op);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsDatagram", "False", op);
- testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsSecure", "False", op);
+ testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsSecure", isSecure, op);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "60000", op);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointCompress", "False", op);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointHost", "127.0.0.1", op);
@@ -1044,7 +1056,7 @@ public class AllTests : TestCommon.TestApp
testAttribute(clientMetrics, clientProps, update, "Invocation", "encoding", "1.1", op);
testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "twoway", op);
testAttribute(clientMetrics, clientProps, update, "Invocation", "proxy",
- "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 60000", op);
+ "metrics -t -e 1.1:" + endpoint + " -t 60000", op);
testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry1", "test", op);
testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry2", "", op);
@@ -1057,7 +1069,7 @@ public class AllTests : TestCommon.TestApp
props["IceMX.Metrics.View.Map.Invocation.GroupBy"] = "operation";
props["IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy"] = "localPort";
updateProps(clientProps, serverProps, update, props, "Invocation");
-
+
MetricsPrx metricsOneway = (MetricsPrx)metrics.ice_oneway();
metricsOneway.op();
metricsOneway.end_op(metricsOneway.begin_op());
@@ -1073,7 +1085,7 @@ public class AllTests : TestCommon.TestApp
test(rim1.current <= 1 && rim1.total == 3 && rim1.failures == 0);
test(rim1.size == 63 && rim1.replySize == 0);
- testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "oneway",
+ testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "oneway",
() => { invokeOp(metricsOneway); });
//
@@ -1082,7 +1094,7 @@ public class AllTests : TestCommon.TestApp
props["IceMX.Metrics.View.Map.Invocation.GroupBy"] = "operation";
props["IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy"] = "localPort";
updateProps(clientProps, serverProps, update, props, "Invocation");
-
+
MetricsPrx metricsBatchOneway = (MetricsPrx)metrics.ice_batchOneway();
metricsBatchOneway.op();
metricsBatchOneway.end_op(metricsBatchOneway.begin_op());
@@ -1095,8 +1107,8 @@ public class AllTests : TestCommon.TestApp
test(im1.current == 0 && im1.total == 2 && im1.failures == 0 && im1.retry == 0);
test(im1.remotes.Length == 0);
- testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "batch-oneway",
- () => { invokeOp(metricsBatchOneway); });
+ testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "batch-oneway",
+ () => { invokeOp(metricsBatchOneway); });
WriteLine("ok");
diff --git a/csharp/test/Ice/networkProxy/AllTests.cs b/csharp/test/Ice/networkProxy/AllTests.cs
index 16f79c7e9b2..455fe310c60 100644
--- a/csharp/test/Ice/networkProxy/AllTests.cs
+++ b/csharp/test/Ice/networkProxy/AllTests.cs
@@ -9,6 +9,18 @@
public class AllTests : TestCommon.TestApp
{
+ private static Ice.IPConnectionInfo getIPConnectionInfo(Ice.ConnectionInfo info)
+ {
+ for(; info != null; info = info.underlying)
+ {
+ if(info is Ice.IPConnectionInfo)
+ {
+ return info as Ice.IPConnectionInfo;
+ }
+ }
+ return null;
+ }
+
public static void allTests(Ice.Communicator communicator)
{
string sref = "test:default -p 12010";
@@ -28,7 +40,7 @@ public class AllTests : TestCommon.TestApp
Write("testing connection information... ");
Flush();
{
- Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)testPrx.ice_getConnection().getInfo();
+ Ice.IPConnectionInfo info = getIPConnectionInfo(testPrx.ice_getConnection().getInfo());
test(info.remotePort == 12030 || info.remotePort == 12031); // make sure we are connected to the proxy port.
}
WriteLine("ok");
diff --git a/csharp/test/IceSSL/configuration/AllTests.cs b/csharp/test/IceSSL/configuration/AllTests.cs
index 5796b351cb5..57be8a29664 100644
--- a/csharp/test/IceSSL/configuration/AllTests.cs
+++ b/csharp/test/IceSSL/configuration/AllTests.cs
@@ -2288,10 +2288,10 @@ public class AllTests
initData.properties.setProperty("IceSSL.UsePlatformCAs", "1");
comm = Ice.Util.initialize(initData);
p = comm.stringToProxy("dummy:wss -h demo.zeroc.com -p 5064");
- IceSSL.WSSConnectionInfo info;
+ IceSSL.ConnectionInfo info;
try
{
- info = (IceSSL.WSSConnectionInfo)p.ice_getConnection().getInfo();
+ info = (IceSSL.ConnectionInfo)p.ice_getConnection().getInfo().underlying;
test(info.verified);
}
catch(Ice.LocalException)
diff --git a/csharp/test/IceSSL/configuration/TestI.cs b/csharp/test/IceSSL/configuration/TestI.cs
index 4b86136b6c6..b144dc0af9d 100644
--- a/csharp/test/IceSSL/configuration/TestI.cs
+++ b/csharp/test/IceSSL/configuration/TestI.cs
@@ -98,7 +98,6 @@ internal sealed class ServerFactoryI : ServerFactoryDisp_
{
initData.properties.setProperty(key, props[key]);
}
-
string[] args = new string[0];
Ice.Communicator communicator = Ice.Util.initialize(ref args, initData);
Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("ServerAdapter", "ssl");
@@ -106,7 +105,6 @@ internal sealed class ServerFactoryI : ServerFactoryDisp_
Ice.ObjectPrx obj = adapter.addWithUUID(server);
servers_[obj.ice_getIdentity()] = server;
adapter.activate();
-
return ServerPrxHelper.uncheckedCast(obj);
}
diff --git a/java/allTests.py b/java/allTests.py
index adb498200f0..7ca52f7db4c 100755
--- a/java/allTests.py
+++ b/java/allTests.py
@@ -70,7 +70,7 @@ tests = [
("Ice/hash", ["once"]),
("Ice/optional", ["once"]),
("Ice/admin", ["core"]),
- ("Ice/metrics", ["core", "nossl", "nows", "noipv6", "nocompress", "nosocks"]),
+ ("Ice/metrics", ["core", "nows", "noipv6", "nocompress", "nosocks"]),
("Ice/enums", ["once"]),
("Ice/networkProxy", ["core", "noipv6", "nosocks"]),
("IceBox/admin", ["core", "noipv6", "nomx"]),
diff --git a/java/src/Ice/src/main/java/Ice/ConnectionI.java b/java/src/Ice/src/main/java/Ice/ConnectionI.java
index 31efd7b40f1..76e42a41b99 100644
--- a/java/src/Ice/src/main/java/Ice/ConnectionI.java
+++ b/java/src/Ice/src/main/java/Ice/ConnectionI.java
@@ -2709,9 +2709,12 @@ public final class ConnectionI extends IceInternal.EventHandler
{
_info = new ConnectionInfo();
}
- _info.connectionId = _endpoint.connectionId();
- _info.adapterName = _adapter != null ? _adapter.getName() : "";
- _info.incoming = _connector == null;
+ for(ConnectionInfo info = _info; info != null; info = info.underlying)
+ {
+ info.connectionId = _endpoint.connectionId();
+ info.adapterName = _adapter != null ? _adapter.getName() : "";
+ info.incoming = _connector == null;
+ }
return _info;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java b/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java
index 14dd81f0d38..5b9f377d807 100644
--- a/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java
+++ b/java/src/Ice/src/main/java/IceInternal/CommunicatorObserverI.java
@@ -56,22 +56,22 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public class ConnectionHelper extends MetricsHelper<ConnectionMetrics>
{
static private AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- add("parent", ConnectionHelper.class.getDeclaredMethod("getParent"));
- add("id", ConnectionHelper.class.getDeclaredMethod("getId"));
- add("state", ConnectionHelper.class.getDeclaredMethod("getState"));
- addConnectionAttributes(this, ConnectionHelper.class);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ add("parent", ConnectionHelper.class.getDeclaredMethod("getParent"));
+ add("id", ConnectionHelper.class.getDeclaredMethod("getId"));
+ add("state", ConnectionHelper.class.getDeclaredMethod("getState"));
+ addConnectionAttributes(this, ConnectionHelper.class);
}
- };
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
+ }
+ }
+ };
ConnectionHelper(Ice.ConnectionInfo con, Ice.Endpoint endpt, Ice.Instrumentation.ConnectionState state)
{
@@ -87,9 +87,9 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
if(_id == null)
{
StringBuilder os = new StringBuilder();
- if(_connectionInfo instanceof Ice.IPConnectionInfo)
+ Ice.IPConnectionInfo info = getIPConnectionInfo();
+ if(info != null)
{
- Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)_connectionInfo;
os.append(info.localAddress).append(':').append(info.localPort);
os.append(" -> ");
os.append(info.remoteAddress).append(':').append(info.remotePort);
@@ -163,6 +163,19 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
return _endpointInfo;
}
+ private Ice.IPConnectionInfo
+ getIPConnectionInfo()
+ {
+ for(Ice.ConnectionInfo p = _connectionInfo; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ return (Ice.IPConnectionInfo)p;
+ }
+ }
+ return null;
+ }
+
private final Ice.ConnectionInfo _connectionInfo;
private final Ice.Endpoint _endpoint;
private final Ice.Instrumentation.ConnectionState _state;
@@ -173,30 +186,30 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class DispatchHelper extends MetricsHelper<DispatchMetrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- Class<?> cl = DispatchHelper.class;
- add("parent", cl.getDeclaredMethod("getParent"));
- add("id", cl.getDeclaredMethod("getId"));
-
- addConnectionAttributes(this, cl);
-
- Class<?> clc = Ice.Current.class;
- add("operation", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("operation"));
- add("identity", cl.getDeclaredMethod("getIdentity"));
- add("facet", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("facet"));
- add("requestId", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("requestId"));
- add("mode", cl.getDeclaredMethod("getMode"));
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ Class<?> cl = DispatchHelper.class;
+ add("parent", cl.getDeclaredMethod("getParent"));
+ add("id", cl.getDeclaredMethod("getId"));
+
+ addConnectionAttributes(this, cl);
+
+ Class<?> clc = Ice.Current.class;
+ add("operation", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("operation"));
+ add("identity", cl.getDeclaredMethod("getIdentity"));
+ add("facet", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("facet"));
+ add("requestId", cl.getDeclaredMethod("getCurrent"), clc.getDeclaredField("requestId"));
+ add("mode", cl.getDeclaredMethod("getMode"));
}
- };
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
+ }
+ }
+ };
DispatchHelper(Ice.Current current, int size)
{
@@ -318,30 +331,30 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class InvocationHelper extends MetricsHelper<InvocationMetrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- Class<?> cl = InvocationHelper.class;
- add("parent", cl.getDeclaredMethod("getParent"));
- add("id", cl.getDeclaredMethod("getId"));
-
- add("operation", cl.getDeclaredMethod("getOperation"));
- add("identity", cl.getDeclaredMethod("getIdentity"));
-
- Class<?> cli = Ice.ObjectPrx.class;
- add("facet", cl.getDeclaredMethod("getProxy"), cli.getDeclaredMethod("ice_getFacet"));
- add("encoding", cl.getDeclaredMethod("getEncodingVersion"));
- add("mode", cl.getDeclaredMethod("getMode"));
- add("proxy", cl.getDeclaredMethod("getProxy"));
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ Class<?> cl = InvocationHelper.class;
+ add("parent", cl.getDeclaredMethod("getParent"));
+ add("id", cl.getDeclaredMethod("getId"));
+
+ add("operation", cl.getDeclaredMethod("getOperation"));
+ add("identity", cl.getDeclaredMethod("getIdentity"));
+
+ Class<?> cli = Ice.ObjectPrx.class;
+ add("facet", cl.getDeclaredMethod("getProxy"), cli.getDeclaredMethod("ice_getFacet"));
+ add("encoding", cl.getDeclaredMethod("getEncodingVersion"));
+ add("mode", cl.getDeclaredMethod("getMode"));
+ add("proxy", cl.getDeclaredMethod("getProxy"));
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
}
- };
+ }
+ };
InvocationHelper(Ice.ObjectPrx proxy, String op, java.util.Map<String, String> ctx)
{
@@ -476,19 +489,19 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class ThreadHelper extends MetricsHelper<ThreadMetrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- add("parent", ThreadHelper.class.getDeclaredField("_parent"));
- add("id", ThreadHelper.class.getDeclaredField("_id"));
- }
- catch(Exception ex)
- {
- assert(false);
- }
+ add("parent", ThreadHelper.class.getDeclaredField("_parent"));
+ add("id", ThreadHelper.class.getDeclaredField("_id"));
+ }
+ catch(Exception ex)
+ {
+ assert(false);
}
- };
+ }
+ };
ThreadHelper(String parent, String id, Ice.Instrumentation.ThreadState state)
{
@@ -526,21 +539,21 @@ public class CommunicatorObserverI implements Ice.Instrumentation.CommunicatorOb
static public final class EndpointHelper extends MetricsHelper<Metrics>
{
static private final AttributeResolver _attributes = new AttributeResolver()
+ {
{
+ try
{
- try
- {
- add("parent", EndpointHelper.class.getDeclaredMethod("getParent"));
- add("id", EndpointHelper.class.getDeclaredMethod("getId"));
- addEndpointAttributes(this, EndpointHelper.class);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- assert(false);
- }
+ add("parent", EndpointHelper.class.getDeclaredMethod("getParent"));
+ add("id", EndpointHelper.class.getDeclaredMethod("getId"));
+ addEndpointAttributes(this, EndpointHelper.class);
}
- };
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ assert(false);
+ }
+ }
+ };
EndpointHelper(Ice.Endpoint endpt, String id)
{
diff --git a/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java
index 9bf0f80cc66..350a9aa7e15 100644
--- a/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/EndpointFactory.java
@@ -17,5 +17,5 @@ public interface EndpointFactory
EndpointI read(Ice.InputStream s);
void destroy();
- EndpointFactory clone(ProtocolInstance instance);
+ EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate);
}
diff --git a/java/src/Ice/src/main/java/IceInternal/EndpointI.java b/java/src/Ice/src/main/java/IceInternal/EndpointI.java
index 9b4b06036b4..d393916472d 100644
--- a/java/src/Ice/src/main/java/IceInternal/EndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/EndpointI.java
@@ -11,6 +11,13 @@ package IceInternal;
abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<EndpointI>
{
+ public void streamWrite(Ice.OutputStream s)
+ {
+ s.startEncapsulation();
+ streamWriteImpl(s);
+ s.endEncapsulation();
+ }
+
@Override
public String toString()
{
@@ -33,7 +40,7 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<En
//
// Marshal the endpoint.
//
- public abstract void streamWrite(Ice.OutputStream s);
+ public abstract void streamWriteImpl(Ice.OutputStream s);
//
// Return the endpoint type.
diff --git a/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java b/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java
index c44434a204c..7a6057800c6 100644
--- a/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/IPEndpointI.java
@@ -43,14 +43,6 @@ public abstract class IPEndpointI extends EndpointI
}
@Override
- public void streamWrite(Ice.OutputStream s)
- {
- s.startEncapsulation();
- streamWriteImpl(s);
- s.endEncapsulation();
- }
-
- @Override
public Ice.EndpointInfo getInfo()
{
Ice.IPEndpointInfo info = new Ice.IPEndpointInfo()
@@ -250,16 +242,7 @@ public abstract class IPEndpointI extends EndpointI
return _connectionId.compareTo(p._connectionId);
}
- public String host()
- {
- return _host;
- }
-
- public int port()
- {
- return _port;
- }
-
+ @Override
public void streamWriteImpl(Ice.OutputStream s)
{
s.writeString(_host);
@@ -280,6 +263,8 @@ public abstract class IPEndpointI extends EndpointI
public void fillEndpointInfo(Ice.IPEndpointInfo info)
{
+ info.timeout = timeout();
+ info.compress = compress();
info.host = _host;
info.port = _port;
info.sourceAddress = _sourceAddr == null ? "" : _sourceAddr.getAddress().getHostAddress();
diff --git a/java/src/Ice/src/main/java/IceInternal/IncomingBase.java b/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
index dfd2fb354b7..151343941af 100644
--- a/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
+++ b/java/src/Ice/src/main/java/IceInternal/IncomingBase.java
@@ -240,12 +240,13 @@ class IncomingBase
out.print("\noperation: " + _current.operation);
if(_current.con != null)
{
- Ice.ConnectionInfo connInfo = _current.con.getInfo();
- if(connInfo instanceof Ice.IPConnectionInfo)
+ for(Ice.ConnectionInfo connInfo = _current.con.getInfo(); connInfo != null; connInfo = connInfo.underlying)
{
- Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo;
- out.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " +
- Integer.toString(ipConnInfo.remotePort));
+ if(connInfo instanceof Ice.IPConnectionInfo)
+ {
+ Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo;
+ out.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " + ipConnInfo.remotePort);
+ }
}
}
out.print("\n");
diff --git a/java/src/Ice/src/main/java/IceInternal/Instance.java b/java/src/Ice/src/main/java/IceInternal/Instance.java
index 1eeb4a3727f..1f019001136 100644
--- a/java/src/Ice/src/main/java/IceInternal/Instance.java
+++ b/java/src/Ice/src/main/java/IceInternal/Instance.java
@@ -1162,13 +1162,13 @@ public final class Instance implements Ice.ClassResolver
if(tcpFactory != null)
{
final ProtocolInstance instance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance)));
+ _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance, null)));
}
final EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value);
if(sslFactory != null)
{
final ProtocolInstance instance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true);
- _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance)));
+ _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance, null)));
}
//
diff --git a/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java b/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java
index 3c825f02cea..c6c6b849ba5 100644
--- a/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/OpaqueEndpointI.java
@@ -52,31 +52,37 @@ final class OpaqueEndpointI extends EndpointI
s.endEncapsulation();
}
+ @Override
+ public void streamWriteImpl(Ice.OutputStream s)
+ {
+ assert(false);
+ }
+
//
// Return the endpoint information.
//
@Override
public Ice.EndpointInfo getInfo()
{
- return new Ice.OpaqueEndpointInfo(-1, false, _rawEncoding, _rawBytes)
+ return new Ice.OpaqueEndpointInfo(null, -1, false, _rawEncoding, _rawBytes)
+ {
+ @Override
+ public short type()
{
- @Override
- public short type()
- {
- return _type;
- }
+ return _type;
+ }
- @Override
- public boolean datagram()
- {
- return false;
- }
+ @Override
+ public boolean datagram()
+ {
+ return false;
+ }
- @Override
- public boolean secure()
- {
- return false;
- }
+ @Override
+ public boolean secure()
+ {
+ return false;
+ }
};
}
diff --git a/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java
index fb4e922b089..9211951ca59 100644
--- a/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/TcpEndpointFactory.java
@@ -49,7 +49,7 @@ final class TcpEndpointFactory implements EndpointFactory
}
@Override
- public EndpointFactory clone(ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate)
{
return new TcpEndpointFactory(instance);
}
diff --git a/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java b/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java
index 687bed96f99..f038da63a2d 100644
--- a/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/TcpEndpointI.java
@@ -9,7 +9,7 @@
package IceInternal;
-final class TcpEndpointI extends IPEndpointI implements WSEndpointDelegate
+final class TcpEndpointI extends IPEndpointI
{
public TcpEndpointI(ProtocolInstance instance, String ho, int po, java.net.InetSocketAddress sourceAddr, int ti,
String conId, boolean co)
@@ -64,37 +64,6 @@ final class TcpEndpointI extends IPEndpointI implements WSEndpointDelegate
}
//
- // Return the WebSocket endpoint information.
- //
- @Override
- public Ice.EndpointInfo getWSInfo(String resource)
- {
- Ice.WSEndpointInfo info = new Ice.WSEndpointInfo()
- {
- @Override
- public short type()
- {
- return TcpEndpointI.this.type();
- }
-
- @Override
- public boolean datagram()
- {
- return TcpEndpointI.this.datagram();
- }
-
- @Override
- public boolean secure()
- {
- return TcpEndpointI.this.secure();
- }
- };
- fillEndpointInfo(info);
- info.resource = resource;
- return info;
- }
-
- //
// Return the timeout for the endpoint in milliseconds. 0 means
// non-blocking, -1 means no timeout.
//
@@ -270,14 +239,6 @@ final class TcpEndpointI extends IPEndpointI implements WSEndpointDelegate
}
@Override
- public void fillEndpointInfo(Ice.IPEndpointInfo info)
- {
- super.fillEndpointInfo(info);
- info.timeout = _timeout;
- info.compress = _compress;
- }
-
- @Override
protected boolean checkOption(String option, String argument, String endpoint)
{
if(super.checkOption(option, argument, endpoint))
diff --git a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java
index ce84da8b2b6..069e79a3408 100644
--- a/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java
+++ b/java/src/Ice/src/main/java/IceInternal/TcpTransceiver.java
@@ -9,7 +9,7 @@
package IceInternal;
-final class TcpTransceiver implements Transceiver, WSTransceiverDelegate
+final class TcpTransceiver implements Transceiver
{
@Override
public java.nio.channels.SelectableChannel fd()
@@ -85,16 +85,22 @@ final class TcpTransceiver implements Transceiver, WSTransceiverDelegate
public Ice.ConnectionInfo getInfo()
{
Ice.TCPConnectionInfo info = new Ice.TCPConnectionInfo();
- fillConnectionInfo(info);
- return info;
- }
-
- @Override
- public Ice.ConnectionInfo getWSInfo(java.util.Map<String, String> headers)
- {
- Ice.WSConnectionInfo info = new Ice.WSConnectionInfo();
- fillConnectionInfo(info);
- info.headers = headers; // Provided header is a copy so no need to clone here.
+ if(_stream.fd() != null)
+ {
+ java.net.Socket socket = _stream.fd().socket();
+ info.localAddress = socket.getLocalAddress().getHostAddress();
+ info.localPort = socket.getLocalPort();
+ if(socket.getInetAddress() != null)
+ {
+ info.remoteAddress = socket.getInetAddress().getHostAddress();
+ info.remotePort = socket.getPort();
+ }
+ if(!socket.isClosed())
+ {
+ info.rcvSize = Network.getRecvBufferSize(_stream.fd());
+ info.sndSize = Network.getSendBufferSize(_stream.fd());
+ }
+ }
return info;
}
@@ -115,26 +121,6 @@ final class TcpTransceiver implements Transceiver, WSTransceiverDelegate
_stream = stream;
}
- private void fillConnectionInfo(Ice.IPConnectionInfo info)
- {
- if(_stream.fd() != null)
- {
- java.net.Socket socket = _stream.fd().socket();
- info.localAddress = socket.getLocalAddress().getHostAddress();
- info.localPort = socket.getLocalPort();
- if(socket.getInetAddress() != null)
- {
- info.remoteAddress = socket.getInetAddress().getHostAddress();
- info.remotePort = socket.getPort();
- }
- if(!socket.isClosed())
- {
- info.rcvSize = Network.getRecvBufferSize(_stream.fd());
- info.sndSize = Network.getSendBufferSize(_stream.fd());
- }
- }
- }
-
final private ProtocolInstance _instance;
final private StreamSocket _stream;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java
index 07f9ad35410..6683b57dcb9 100644
--- a/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/UdpEndpointFactory.java
@@ -49,7 +49,7 @@ final class UdpEndpointFactory implements EndpointFactory
}
@Override
- public EndpointFactory clone(ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate)
{
return new UdpEndpointFactory(instance);
}
diff --git a/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java b/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java
index 8de493bb467..8c1d0bc837d 100644
--- a/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java
+++ b/java/src/Ice/src/main/java/IceInternal/UdpEndpointI.java
@@ -51,26 +51,25 @@ final class UdpEndpointI extends IPEndpointI
public Ice.EndpointInfo getInfo()
{
Ice.UDPEndpointInfo info = new Ice.UDPEndpointInfo()
+ {
+ @Override
+ public short type()
{
- @Override
- public short type()
- {
- return UdpEndpointI.this.type();
- }
+ return UdpEndpointI.this.type();
+ }
- @Override
- public boolean datagram()
- {
- return UdpEndpointI.this.datagram();
- }
+ @Override
+ public boolean datagram()
+ {
+ return UdpEndpointI.this.datagram();
+ }
- @Override
- public boolean secure()
- {
- return UdpEndpointI.this.secure();
- }
+ @Override
+ public boolean secure()
+ {
+ return UdpEndpointI.this.secure();
+ }
};
-
fillEndpointInfo(info);
return info;
}
@@ -283,8 +282,6 @@ final class UdpEndpointI extends IPEndpointI
if(info instanceof Ice.UDPEndpointInfo)
{
Ice.UDPEndpointInfo udpInfo = (Ice.UDPEndpointInfo)info;
- udpInfo.timeout = -1;
- udpInfo.compress = _compress;
udpInfo.mcastInterface = _mcastInterface;
udpInfo.mcastTtl = _mcastTtl;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSConnector.java b/java/src/Ice/src/main/java/IceInternal/WSConnector.java
index 3e2978e03ee..3c9ecc7e06b 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSConnector.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSConnector.java
@@ -14,7 +14,7 @@ final class WSConnector implements Connector
@Override
public Transceiver connect()
{
- return new WSTransceiver(_instance, _delegate.connect(), _host, _port, _resource);
+ return new WSTransceiver(_instance, _delegate.connect(), _host, _resource);
}
@Override
@@ -35,12 +35,11 @@ final class WSConnector implements Connector
return _delegate.hashCode();
}
- WSConnector(ProtocolInstance instance, Connector del, String host, int port, String resource)
+ WSConnector(ProtocolInstance instance, Connector del, String host, String resource)
{
_instance = instance;
_delegate = del;
_host = host;
- _port = port;
_resource = resource;
}
@@ -74,6 +73,5 @@ final class WSConnector implements Connector
private ProtocolInstance _instance;
private Connector _delegate;
private String _host;
- private int _port;
private String _resource;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java b/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java
index 8b34032ec5f..91ea36d1a62 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSEndpoint.java
@@ -14,14 +14,14 @@ final class WSEndpoint extends IceInternal.EndpointI
public WSEndpoint(ProtocolInstance instance, EndpointI del, String res)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
_resource = res;
}
public WSEndpoint(ProtocolInstance instance, EndpointI del, java.util.ArrayList<String> args)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
initWithOptions(args);
@@ -34,15 +34,36 @@ final class WSEndpoint extends IceInternal.EndpointI
public WSEndpoint(ProtocolInstance instance, EndpointI del, Ice.InputStream s)
{
_instance = instance;
- _delegate = (IPEndpointI)del;
+ _delegate = del;
_resource = s.readString();
}
@Override
public Ice.EndpointInfo getInfo()
{
- assert(_delegate instanceof WSEndpointDelegate);
- return ((WSEndpointDelegate)_delegate).getWSInfo(_resource);
+ Ice.WSEndpointInfo info = new Ice.WSEndpointInfo(_delegate.getInfo(), timeout(), compress(), _resource)
+ {
+ @Override
+ public short type()
+ {
+ return WSEndpoint.this.type();
+ }
+
+ @Override
+ public boolean datagram()
+ {
+ return WSEndpoint.this.datagram();
+ }
+
+ @Override
+ public boolean secure()
+ {
+ return WSEndpoint.this.secure();
+ }
+ };
+ info.compress = info.underlying.compress;
+ info.timeout = info.underlying.timeout;
+ return info;
}
@Override
@@ -58,12 +79,10 @@ final class WSEndpoint extends IceInternal.EndpointI
}
@Override
- public void streamWrite(Ice.OutputStream s)
+ public void streamWriteImpl(Ice.OutputStream s)
{
- s.startEncapsulation();
_delegate.streamWriteImpl(s);
s.writeString(_resource);
- s.endEncapsulation();
}
@Override
@@ -144,6 +163,15 @@ final class WSEndpoint extends IceInternal.EndpointI
@Override
public void connectors_async(Ice.EndpointSelectionType selType, final EndpointI_connectors callback)
{
+ Ice.IPEndpointInfo ipInfo = null;
+ for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPEndpointInfo)
+ {
+ ipInfo = (Ice.IPEndpointInfo)p;
+ }
+ }
+ final String host = ipInfo != null ? (ipInfo.host + ":" + ipInfo.port) : "";
EndpointI_connectors cb = new EndpointI_connectors()
{
@Override
@@ -152,7 +180,7 @@ final class WSEndpoint extends IceInternal.EndpointI
java.util.List<Connector> l = new java.util.ArrayList<Connector>();
for(Connector c : connectors)
{
- l.add(new WSConnector(_instance, c, _delegate.host(), _delegate.port(), _resource));
+ l.add(new WSConnector(_instance, c, host, _resource));
}
callback.connectors(l);
}
@@ -291,6 +319,6 @@ final class WSEndpoint extends IceInternal.EndpointI
}
private ProtocolInstance _instance;
- private IPEndpointI _delegate;
+ private EndpointI _delegate;
private String _resource;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java b/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java
index dc2ad44e561..493cddfd5eb 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSEndpointFactory.java
@@ -9,9 +9,9 @@
package IceInternal;
-final public class WSEndpointFactory implements IceInternal.EndpointFactory
+final public class WSEndpointFactory implements EndpointFactory
{
- public WSEndpointFactory(ProtocolInstance instance, IceInternal.EndpointFactory delegate)
+ public WSEndpointFactory(ProtocolInstance instance, EndpointFactory delegate)
{
_instance = instance;
_delegate = delegate;
@@ -30,13 +30,13 @@ final public class WSEndpointFactory implements IceInternal.EndpointFactory
}
@Override
- public IceInternal.EndpointI create(java.util.ArrayList<String> args, boolean oaEndpoint)
+ public EndpointI create(java.util.ArrayList<String> args, boolean oaEndpoint)
{
return new WSEndpoint(_instance, _delegate.create(args, oaEndpoint), args);
}
@Override
- public IceInternal.EndpointI read(Ice.InputStream s)
+ public EndpointI read(Ice.InputStream s)
{
return new WSEndpoint(_instance, _delegate.read(s), s);
}
@@ -49,12 +49,11 @@ final public class WSEndpointFactory implements IceInternal.EndpointFactory
}
@Override
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public EndpointFactory clone(ProtocolInstance instance, EndpointFactory delegate)
{
- assert(false); // We don't support cloning this transport.
- return null;
+ return new WSEndpointFactory(instance, delegate);
}
private ProtocolInstance _instance;
- private IceInternal.EndpointFactory _delegate;
+ private EndpointFactory _delegate;
}
diff --git a/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java
index 217e866d1d6..8188ab322c8 100644
--- a/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java
+++ b/java/src/Ice/src/main/java/IceInternal/WSTransceiver.java
@@ -65,8 +65,7 @@ final class WSTransceiver implements Transceiver
//
StringBuffer out = new StringBuffer();
out.append("GET " + _resource + " HTTP/1.1\r\n");
- out.append("Host: " + _host + ":");
- out.append(_port);
+ out.append("Host: " + _host);
out.append("\r\n");
out.append("Upgrade: websocket\r\n");
out.append("Connection: Upgrade\r\n");
@@ -498,8 +497,10 @@ final class WSTransceiver implements Transceiver
@Override
public Ice.ConnectionInfo getInfo()
{
- assert(_delegate instanceof WSTransceiverDelegate);
- return ((WSTransceiverDelegate)_delegate).getWSInfo(_parser.getHeaders());
+ Ice.WSConnectionInfo info = new Ice.WSConnectionInfo();
+ info.underlying = _delegate.getInfo();
+ info.headers = _parser.getHeaders();
+ return info;
}
@Override
@@ -514,11 +515,10 @@ final class WSTransceiver implements Transceiver
_delegate.setBufferSize(rcvSize, sndSize);
}
- WSTransceiver(ProtocolInstance instance, Transceiver del, String host, int port, String resource)
+ WSTransceiver(ProtocolInstance instance, Transceiver del, String host, String resource)
{
init(instance, del);
_host = host;
- _port = port;
_resource = resource;
_incoming = false;
@@ -542,7 +542,6 @@ final class WSTransceiver implements Transceiver
{
init(instance, del);
_host = "";
- _port = -1;
_resource = "";
_incoming = true;
@@ -1516,7 +1515,6 @@ final class WSTransceiver implements Transceiver
private ProtocolInstance _instance;
private Transceiver _delegate;
private String _host;
- private int _port;
private String _resource;
private boolean _incoming;
private ReadyCallback _readyCallback;
diff --git a/java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java b/java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java
deleted file mode 100644
index 2cce1ae1d99..00000000000
--- a/java/src/Ice/src/main/java/IceInternal/WSTransceiverDelegate.java
+++ /dev/null
@@ -1,19 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package IceInternal;
-
-//
-// Delegate interface implemented by TcpTransceiver or IceSSL.TransceiverI or any endpoint that WS can
-// delegate to.
-//
-public interface WSTransceiverDelegate
-{
- Ice.ConnectionInfo getWSInfo(java.util.Map<String, String> headers);
-};
diff --git a/java/src/Ice/src/main/java/IceMX/MetricsHelper.java b/java/src/Ice/src/main/java/IceMX/MetricsHelper.java
index d2befeef9cb..8d5aac39062 100644
--- a/java/src/Ice/src/main/java/IceMX/MetricsHelper.java
+++ b/java/src/Ice/src/main/java/IceMX/MetricsHelper.java
@@ -67,7 +67,7 @@ public class MetricsHelper<T>
}
public void
- add(String name, final java.lang.reflect.Method method)
+ add(final String name, final java.lang.reflect.Method method)
{
_attributes.put(name, new Resolver()
{
@@ -81,7 +81,7 @@ public class MetricsHelper<T>
}
public void
- add(String name, final java.lang.reflect.Field field)
+ add(final String name, final java.lang.reflect.Field field)
{
_attributes.put(name, new Resolver()
{
@@ -89,7 +89,7 @@ public class MetricsHelper<T>
public Object
resolve(Object obj) throws Exception
{
- return field.get(obj);
+ return getField(name, field, obj);
}
});
}
@@ -103,12 +103,7 @@ public class MetricsHelper<T>
public Object
resolve(Object obj) throws Exception
{
- Object o = method.invoke(obj);
- if(o != null)
- {
- return field.get(o);
- }
- throw new IllegalArgumentException(name);
+ return getField(name, field, method.invoke(obj));
}
});
}
@@ -132,6 +127,36 @@ public class MetricsHelper<T>
});
}
+ private Object getField(String name, java.lang.reflect.Field field, Object o)
+ throws IllegalArgumentException, IllegalAccessException
+ {
+ while(o != null)
+ {
+ try
+ {
+ return field.get(o);
+ }
+ catch(IllegalArgumentException ex)
+ {
+ // If we're dealing with an endpoint/connection information class,
+ // check if the field is from the underlying info objects.
+ if(o instanceof Ice.EndpointInfo)
+ {
+ o = ((Ice.EndpointInfo)o).underlying;
+ }
+ else if(o instanceof Ice.ConnectionInfo)
+ {
+ o = ((Ice.ConnectionInfo)o).underlying;
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ }
+ throw new IllegalArgumentException(name);
+ }
+
private java.util.Map<String, Resolver> _attributes = new java.util.HashMap<String, Resolver>();
}
diff --git a/java/src/Ice/src/main/java/IceSSL/AcceptorI.java b/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
index 639b8072f1b..bf21888839e 100644
--- a/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
+++ b/java/src/Ice/src/main/java/IceSSL/AcceptorI.java
@@ -14,38 +14,25 @@ final class AcceptorI implements IceInternal.Acceptor
@Override
public java.nio.channels.ServerSocketChannel fd()
{
- return _fd;
+ return _delegate.fd();
}
@Override
public void setReadyCallback(IceInternal.ReadyCallback callback)
{
- // No need to for the ready callback.
+ _delegate.setReadyCallback(callback);
}
@Override
public void close()
{
- if(_fd != null)
- {
- IceInternal.Network.closeSocketNoThrow(_fd);
- _fd = null;
- }
+ _delegate.close();
}
@Override
public IceInternal.EndpointI listen()
{
- try
- {
- _addr = IceInternal.Network.doBind(_fd, _addr, _backlog);
- }
- catch(Ice.Exception ex)
- {
- _fd = null;
- throw ex;
- }
- _endpoint = _endpoint.endpoint(this);
+ _endpoint = _endpoint.endpoint(_delegate.listen());
return _endpoint;
}
@@ -62,114 +49,37 @@ final class AcceptorI implements IceInternal.Acceptor
throw ex;
}
- IceInternal.StreamSocket stream = new IceInternal.StreamSocket(_instance, IceInternal.Network.doAccept(_fd));
- try
- {
- java.net.InetSocketAddress peerAddr =
- (java.net.InetSocketAddress)stream.fd().socket().getRemoteSocketAddress();
- return new TransceiverI(_instance, _instance.createSSLEngine(true, peerAddr), stream, _adapterName, true);
- }
- catch(RuntimeException ex)
- {
- stream.close();
- throw ex;
- }
+ return new TransceiverI(_instance, _delegate.accept(), _adapterName, true);
}
@Override
public String protocol()
{
- return _instance.protocol();
+ return _delegate.protocol();
}
@Override
public String toString()
{
- return IceInternal.Network.addrToString(_addr);
+ return _delegate.toString();
}
@Override
public String toDetailedString()
{
- StringBuffer s = new StringBuffer("local address = ");
- s.append(toString());
-
- java.util.List<String> intfs =
- IceInternal.Network.getHostsForEndpointExpand(_addr.getAddress().getHostAddress(),
- _instance.protocolSupport(), true);
- if(!intfs.isEmpty())
- {
- s.append("\nlocal interfaces = ");
- s.append(IceUtilInternal.StringUtil.joinString(intfs, ", "));
- }
- return s.toString();
- }
-
- int effectivePort()
- {
- return _addr.getPort();
+ return _delegate.toDetailedString();
}
- AcceptorI(EndpointI endpoint, Instance instance, String adapterName, String host, int port)
+ AcceptorI(EndpointI endpoint, Instance instance, IceInternal.Acceptor delegate, String adapterName)
{
_endpoint = endpoint;
_instance = instance;
+ _delegate = delegate;
_adapterName = adapterName;
- _backlog = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.Backlog", 511);
-
- try
- {
- _fd = IceInternal.Network.createTcpServerSocket();
- IceInternal.Network.setBlock(_fd, false);
- IceInternal.Network.setTcpBufSize(_fd, _instance);
- if(!System.getProperty("os.name").startsWith("Windows"))
- {
- //
- // Enable SO_REUSEADDR on Unix platforms to allow
- // re-using the socket even if it's in the TIME_WAIT
- // state. On Windows, this doesn't appear to be
- // necessary and enabling SO_REUSEADDR would actually
- // not be a good thing since it allows a second
- // process to bind to an address even it's already
- // bound by another process.
- //
- // TODO: using SO_EXCLUSIVEADDRUSE on Windows would
- // probably be better but it's only supported by recent
- // Windows versions (XP SP2, Windows Server 2003).
- //
- IceInternal.Network.setReuseAddress(_fd, true);
- }
- _addr = IceInternal.Network.getAddressForServer(host, port, _instance.protocolSupport(),
- _instance.preferIPv6());
- }
- catch(RuntimeException ex)
- {
- _fd = null;
- throw ex;
- }
- }
-
- @Override
- protected synchronized void finalize()
- throws Throwable
- {
- try
- {
- IceUtilInternal.Assert.FinalizerAssert(_fd == null);
- }
- catch(java.lang.Exception ex)
- {
- }
- finally
- {
- super.finalize();
- }
}
private EndpointI _endpoint;
private Instance _instance;
+ private IceInternal.Acceptor _delegate;
private String _adapterName;
- private java.nio.channels.ServerSocketChannel _fd;
- private int _backlog;
- private java.net.InetSocketAddress _addr;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/ConnectorI.java b/java/src/Ice/src/main/java/IceSSL/ConnectorI.java
index 4a47254e006..d463a89bf3d 100644
--- a/java/src/Ice/src/main/java/IceSSL/ConnectorI.java
+++ b/java/src/Ice/src/main/java/IceSSL/ConnectorI.java
@@ -24,60 +24,35 @@ final class ConnectorI implements IceInternal.Connector
throw ex;
}
- IceInternal.StreamSocket stream = new IceInternal.StreamSocket(_instance, _proxy, _addr, _sourceAddr);
- try
- {
- javax.net.ssl.SSLEngine engine = _instance.createSSLEngine(false, _addr);
- return new TransceiverI(_instance, engine, stream, _host, false);
- }
- catch(RuntimeException ex)
- {
- stream.close();
- throw ex;
- }
+ return new TransceiverI(_instance, _delegate.connect(), _host, false);
}
@Override
public short type()
{
- return _instance.type();
+ return _delegate.type();
}
@Override
public String toString()
{
- return IceInternal.Network.addrToString(_proxy == null ? _addr : _proxy.getAddress());
+ return _delegate.toString();
}
@Override
public int hashCode()
{
- return _hashCode;
+ return _delegate.hashCode();
}
//
// Only for use by EndpointI.
//
- ConnectorI(Instance instance, String host, java.net.InetSocketAddress addr, IceInternal.NetworkProxy proxy,
- java.net.InetSocketAddress sourceAddr, int timeout, String connectionId)
+ ConnectorI(Instance instance, IceInternal.Connector delegate, String host)
{
_instance = instance;
+ _delegate = delegate;
_host = host;
- _addr = addr;
- _sourceAddr = sourceAddr;
- _proxy = proxy;
- _timeout = timeout;
- _connectionId = connectionId;
-
- _hashCode = 5381;
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getAddress().getHostAddress());
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _addr.getPort());
- if(_sourceAddr != null)
- {
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _sourceAddr.getAddress().getHostAddress());
- }
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _timeout);
- _hashCode = IceInternal.HashUtil.hashAdd(_hashCode , _connectionId);
}
@Override
@@ -94,30 +69,10 @@ final class ConnectorI implements IceInternal.Connector
}
ConnectorI p = (ConnectorI)obj;
- if(_timeout != p._timeout)
- {
- return false;
- }
-
- if(!_connectionId.equals(p._connectionId))
- {
- return false;
- }
-
- if(IceInternal.Network.compareAddress(_sourceAddr, p._sourceAddr) != 0)
- {
- return false;
- }
-
- return IceInternal.Network.compareAddress(_addr, p._addr) == 0;
+ return p._delegate.equals(_delegate);
}
private Instance _instance;
+ private IceInternal.Connector _delegate;
private String _host;
- private java.net.InetSocketAddress _addr;
- private IceInternal.NetworkProxy _proxy;
- private java.net.InetSocketAddress _sourceAddr;
- private int _timeout;
- private String _connectionId;
- private int _hashCode;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java b/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java
index f13758a2522..ffe402c6193 100644
--- a/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java
+++ b/java/src/Ice/src/main/java/IceSSL/EndpointFactoryI.java
@@ -11,9 +11,10 @@ package IceSSL;
final class EndpointFactoryI implements IceInternal.EndpointFactory
{
- EndpointFactoryI(Instance instance)
+ EndpointFactoryI(Instance instance, IceInternal.EndpointFactory delegate)
{
_instance = instance;
+ _delegate = delegate;
}
@Override
@@ -31,28 +32,29 @@ final class EndpointFactoryI implements IceInternal.EndpointFactory
@Override
public IceInternal.EndpointI create(java.util.ArrayList<String> args, boolean oaEndpoint)
{
- IceInternal.IPEndpointI endpt = new EndpointI(_instance);
- endpt.initWithOptions(args, oaEndpoint);
- return endpt;
+ return new EndpointI(_instance, _delegate.create(args, oaEndpoint));
}
@Override
public IceInternal.EndpointI read(Ice.InputStream s)
{
- return new EndpointI(_instance, s);
+ return new EndpointI(_instance, _delegate.read(s));
}
@Override
public void destroy()
{
+ _delegate.destroy();
_instance = null;
}
@Override
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst, IceInternal.EndpointFactory delegate)
{
- return new EndpointFactoryI(new Instance(_instance.engine(), instance.type(), instance.protocol()));
+ Instance instance = new Instance(_instance.engine(), inst.type(), inst.protocol());
+ return new EndpointFactoryI(instance, delegate != null ? delegate : _delegate.clone(instance, null));
}
private Instance _instance;
+ private IceInternal.EndpointFactory _delegate;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/EndpointI.java b/java/src/Ice/src/main/java/IceSSL/EndpointI.java
index 105530660d1..08de48c2f11 100644
--- a/java/src/Ice/src/main/java/IceSSL/EndpointI.java
+++ b/java/src/Ice/src/main/java/IceSSL/EndpointI.java
@@ -9,31 +9,18 @@
package IceSSL;
-final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSEndpointDelegate
+final class EndpointI extends IceInternal.EndpointI
{
- public EndpointI(Instance instance, String ho, int po, java.net.InetSocketAddress sourceAddr, int ti, String conId,
- boolean co)
+ public EndpointI(Instance instance, IceInternal.EndpointI delegate)
{
- super(instance, ho, po, sourceAddr, conId);
_instance = instance;
- _timeout = ti;
- _compress = co;
+ _delegate = delegate;
}
- public EndpointI(Instance instance)
- {
- super(instance);
- _instance = instance;
- _timeout = instance.defaultTimeout();
- _compress = false;
- }
-
- public EndpointI(Instance instance, Ice.InputStream s)
+ @Override
+ public void streamWriteImpl(Ice.OutputStream s)
{
- super(instance, s);
- _instance = instance;
- _timeout = s.readInt();
- _compress = s.readBool();
+ _delegate.streamWriteImpl(s);
}
//
@@ -42,7 +29,7 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
@Override
public Ice.EndpointInfo getInfo()
{
- Ice.IPEndpointInfo info = new IceSSL.EndpointInfo()
+ IceSSL.EndpointInfo info = new IceSSL.EndpointInfo(_delegate.getInfo(), timeout(), compress())
{
@Override
public short type()
@@ -62,104 +49,90 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
return EndpointI.this.secure();
}
};
- fillEndpointInfo(info);
+ info.compress = info.underlying.compress;
+ info.timeout = info.underlying.timeout;
return info;
}
- //
- // Return the secure WebSocket endpoint information.
- //
@Override
- public Ice.EndpointInfo getWSInfo(String resource)
+ public short type()
{
- IceSSL.WSSEndpointInfo info = new IceSSL.WSSEndpointInfo()
- {
- @Override
- public short type()
- {
- return EndpointI.this.type();
- }
-
- @Override
- public boolean datagram()
- {
- return EndpointI.this.datagram();
- }
+ return _delegate.type();
+ }
- @Override
- public boolean secure()
- {
- return EndpointI.this.secure();
- }
- };
- fillEndpointInfo(info);
- info.resource = resource;
- return info;
+ @Override
+ public String protocol()
+ {
+ return _delegate.protocol();
}
- //
- // Return the timeout for the endpoint in milliseconds. 0 means
- // non-blocking, -1 means no timeout.
- //
@Override
public int timeout()
{
- return _timeout;
+ return _delegate.timeout();
}
- //
- // Return a new endpoint with a different timeout value, provided
- // that timeouts are supported by the endpoint. Otherwise the same
- // endpoint is returned.
- //
@Override
public IceInternal.EndpointI timeout(int timeout)
{
- if(timeout == _timeout)
+ if(timeout == _delegate.timeout())
{
return this;
}
else
{
- return new EndpointI(_instance, _host, _port, _sourceAddr, timeout, _connectionId, _compress);
+ return new EndpointI(_instance, _delegate.timeout(timeout));
+ }
+ }
+
+ @Override
+ public String connectionId()
+ {
+ return _delegate.connectionId();
+ }
+
+ @Override
+ public IceInternal.EndpointI connectionId(String connectionId)
+ {
+ if(connectionId == _delegate.connectionId())
+ {
+ return this;
+ }
+ else
+ {
+ return new EndpointI(_instance, _delegate.connectionId(connectionId));
}
}
- //
- // Return true if the endpoints support bzip2 compress, or false
- // otherwise.
- //
@Override
public boolean compress()
{
- return _compress;
+ return _delegate.compress();
}
- //
- // Return a new endpoint with a different compression value,
- // provided that compression is supported by the
- // endpoint. Otherwise the same endpoint is returned.
- //
@Override
public IceInternal.EndpointI compress(boolean compress)
{
- if(compress == _compress)
+ if(compress == _delegate.compress())
{
return this;
}
else
{
- return new EndpointI(_instance, _host, _port, _sourceAddr, _timeout, _connectionId, compress);
+ return new EndpointI(_instance, _delegate.compress(compress));
}
}
- //
- // Return true if the endpoint is datagram-based.
- //
@Override
public boolean datagram()
{
- return false;
+ return _delegate.datagram();
+ }
+
+ @Override
+ public boolean secure()
+ {
+ return _delegate.secure();
}
//
@@ -172,6 +145,40 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
return null;
}
+ @Override
+ public void connectors_async(Ice.EndpointSelectionType selType, final IceInternal.EndpointI_connectors callback)
+ {
+ Ice.IPEndpointInfo ipInfo = null;
+ for(Ice.EndpointInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPEndpointInfo)
+ {
+ ipInfo = (Ice.IPEndpointInfo)p;
+ }
+ }
+ final String host = ipInfo != null ? ipInfo.host : "";
+ IceInternal.EndpointI_connectors cb = new IceInternal.EndpointI_connectors()
+ {
+ @Override
+ public void connectors(java.util.List<IceInternal.Connector> connectors)
+ {
+ java.util.List<IceInternal.Connector> l = new java.util.ArrayList<IceInternal.Connector>();
+ for(IceInternal.Connector c : connectors)
+ {
+ l.add(new ConnectorI(_instance, c, host));
+ }
+ callback.connectors(l);
+ }
+
+ @Override
+ public void exception(Ice.LocalException ex)
+ {
+ callback.exception(ex);
+ }
+ };
+ _delegate.connectors_async(selType, cb);
+ }
+
//
// Return an acceptor for this endpoint, or null if no acceptors
// is available.
@@ -179,182 +186,75 @@ final class EndpointI extends IceInternal.IPEndpointI implements IceInternal.WSE
@Override
public IceInternal.Acceptor acceptor(String adapterName)
{
- return new AcceptorI(this, _instance, adapterName, _host, _port);
+ return new AcceptorI(this, _instance, _delegate.acceptor(adapterName), adapterName);
}
- public EndpointI endpoint(AcceptorI acceptor)
+ public EndpointI endpoint(IceInternal.EndpointI delEndpt)
{
- return new EndpointI(_instance, _host, acceptor.effectivePort(), _sourceAddr, _timeout, _connectionId,
- _compress);
+ return new EndpointI(_instance, delEndpt);
}
-
@Override
- public String options()
+ public java.util.List<IceInternal.EndpointI> expand()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
- String s = super.options();
-
- if(_timeout == -1)
- {
- s += " -t infinite";
- }
- else
+ java.util.List<IceInternal.EndpointI> endps = _delegate.expand();
+ java.util.List<IceInternal.EndpointI> l = new java.util.ArrayList<IceInternal.EndpointI>();
+ for(IceInternal.EndpointI e : endps)
{
- s += " -t " + _timeout;
+ l.add(e == _delegate ? this : new EndpointI(_instance, e));
}
-
- if(_compress)
- {
- s += " -z";
- }
-
- return s;
+ return l;
}
- //
- // Compare endpoints for sorting purposes
- //
@Override
- public int compareTo(IceInternal.EndpointI obj) // From java.lang.Comparable
+ public boolean equivalent(IceInternal.EndpointI endpoint)
{
- if(!(obj instanceof EndpointI))
- {
- return type() < obj.type() ? -1 : 1;
- }
-
- EndpointI p = (EndpointI)obj;
- if(this == p)
- {
- return 0;
- }
-
- if(_timeout < p._timeout)
- {
- return -1;
- }
- else if(p._timeout < _timeout)
- {
- return 1;
- }
-
- if(!_compress && p._compress)
+ if(!(endpoint instanceof EndpointI))
{
- return -1;
- }
- else if(!p._compress && _compress)
- {
- return 1;
+ return false;
}
-
- return super.compareTo(obj);
- }
-
- @Override
- public void streamWriteImpl(Ice.OutputStream s)
- {
- super.streamWriteImpl(s);
- s.writeInt(_timeout);
- s.writeBool(_compress);
+ EndpointI endpointI = (EndpointI)endpoint;
+ return _delegate.equivalent(endpointI._delegate);
}
@Override
- public int hashInit(int h)
+ synchronized public int hashCode()
{
- h = super.hashInit(h);
- h = IceInternal.HashUtil.hashAdd(h, _timeout);
- h = IceInternal.HashUtil.hashAdd(h, _compress);
- return h;
+ return _delegate.hashCode();
}
@Override
- public void fillEndpointInfo(Ice.IPEndpointInfo info)
+ public String options()
{
- super.fillEndpointInfo(info);
- info.timeout = _timeout;
- info.compress = _compress;
+ return _delegate.options();
}
+ //
+ // Compare endpoints for sorting purposes
+ //
@Override
- protected boolean checkOption(String option, String argument, String endpoint)
+ public int compareTo(IceInternal.EndpointI obj) // From java.lang.Comparable
{
- if(super.checkOption(option, argument, endpoint))
- {
- return true;
- }
-
- switch(option.charAt(1))
- {
- case 't':
- {
- if(argument == null)
- {
- throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint);
- }
-
- if(argument.equals("infinite"))
- {
- _timeout = -1;
- }
- else
- {
- try
- {
- _timeout = Integer.parseInt(argument);
- if(_timeout < 1)
- {
- throw new Ice.EndpointParseException("invalid timeout value `" + argument +
- "' in endpoint " + endpoint);
- }
- }
- catch(NumberFormatException ex)
- {
- throw new Ice.EndpointParseException("invalid timeout value `" + argument +
- "' in endpoint " + endpoint);
- }
- }
-
- return true;
- }
-
- case 'z':
+ if(!(obj instanceof EndpointI))
{
- if(argument != null)
- {
- throw new Ice.EndpointParseException("unexpected argument `" + argument +
- "' provided for -z option in " + endpoint);
- }
-
- _compress = true;
- return true;
+ return type() < obj.type() ? -1 : 1;
}
- default:
+ EndpointI p = (EndpointI)obj;
+ if(this == p)
{
- return false;
- }
+ return 0;
}
- }
- @Override
- protected IceInternal.Connector createConnector(java.net.InetSocketAddress addr, IceInternal.NetworkProxy proxy)
- {
- return new ConnectorI(_instance, _host, addr, proxy, _sourceAddr, _timeout, _connectionId);
+ return _delegate.compareTo(p._delegate);
}
@Override
- protected IceInternal.IPEndpointI createEndpoint(String host, int port, String connectionId)
+ protected boolean checkOption(String option, String argument, String endpoint)
{
- return new EndpointI(_instance, host, port, _sourceAddr, _timeout, connectionId, _compress);
+ return false;
}
private Instance _instance;
- private int _timeout;
- private boolean _compress;
+ private IceInternal.EndpointI _delegate;
}
diff --git a/java/src/Ice/src/main/java/IceSSL/Instance.java b/java/src/Ice/src/main/java/IceSSL/Instance.java
index 8c18c961933..53ffac5c29f 100644
--- a/java/src/Ice/src/main/java/IceSSL/Instance.java
+++ b/java/src/Ice/src/main/java/IceSSL/Instance.java
@@ -37,19 +37,19 @@ class Instance extends IceInternal.ProtocolInstance
return _engine.initialized();
}
- javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, java.net.InetSocketAddress peerAddr)
+ javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, String host, int port)
{
- return _engine.createSSLEngine(incoming, peerAddr);
+ return _engine.createSSLEngine(incoming, host, port);
}
- void traceConnection(java.nio.channels.SocketChannel fd, javax.net.ssl.SSLEngine engine, boolean incoming)
+ void traceConnection(String desc, javax.net.ssl.SSLEngine engine, boolean incoming)
{
- _engine.traceConnection(fd, engine, incoming);
+ _engine.traceConnection(desc, engine, incoming);
}
- void verifyPeer(NativeConnectionInfo info, java.nio.channels.SelectableChannel fd, String address)
+ void verifyPeer(String address, NativeConnectionInfo info, String desc)
{
- _engine.verifyPeer(info, fd, address);
+ _engine.verifyPeer(address, info, desc);
}
void trustManagerFailure(boolean incoming, java.security.cert.CertificateException ex)
diff --git a/java/src/Ice/src/main/java/IceSSL/PluginI.java b/java/src/Ice/src/main/java/IceSSL/PluginI.java
index 6db69f7c264..a57d6e31245 100644
--- a/java/src/Ice/src/main/java/IceSSL/PluginI.java
+++ b/java/src/Ice/src/main/java/IceSSL/PluginI.java
@@ -21,8 +21,22 @@ class PluginI implements Plugin
// in initialize, because the communicator may need to interpret
// proxies before the plug-in is fully initialized.
//
- EndpointFactoryI factory = new EndpointFactoryI(new Instance(_engine, IceSSL.EndpointType.value, "ssl"));
- facade.addEndpointFactory(factory);
+
+ // SSL based on TCP
+ IceInternal.EndpointFactory tcp = facade.getEndpointFactory(Ice.TCPEndpointType.value);
+ if(tcp != null)
+ {
+ Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl");
+ facade.addEndpointFactory(new EndpointFactoryI(instance, tcp.clone(instance, null)));
+ }
+
+ // SSL based on Bluetooth
+ IceInternal.EndpointFactory bluetooth = facade.getEndpointFactory(Ice.BTEndpointType.value);
+ if(bluetooth != null)
+ {
+ Instance instance = new Instance(_engine, Ice.BTSEndpointType.value, "bts");
+ facade.addEndpointFactory(new EndpointFactoryI(instance, bluetooth.clone(instance, null)));
+ }
}
@Override
diff --git a/java/src/Ice/src/main/java/IceSSL/SSLEngine.java b/java/src/Ice/src/main/java/IceSSL/SSLEngine.java
index 72810753755..e8da76b6b26 100644
--- a/java/src/Ice/src/main/java/IceSSL/SSLEngine.java
+++ b/java/src/Ice/src/main/java/IceSSL/SSLEngine.java
@@ -777,12 +777,12 @@ class SSLEngine
return _initialized;
}
- javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, java.net.InetSocketAddress peerAddr)
+ javax.net.ssl.SSLEngine createSSLEngine(boolean incoming, String host, int port)
{
javax.net.ssl.SSLEngine engine;
- if(peerAddr != null)
+ if(host != null)
{
- engine = _context.createSSLEngine(peerAddr.getAddress().getHostAddress(), peerAddr.getPort());
+ engine = _context.createSSLEngine(host, port);
}
else
{
@@ -941,13 +941,12 @@ class SSLEngine
return _protocols;
}
- void traceConnection(java.nio.channels.SocketChannel fd, javax.net.ssl.SSLEngine engine, boolean incoming)
+ void traceConnection(String desc, javax.net.ssl.SSLEngine engine, boolean incoming)
{
javax.net.ssl.SSLSession session = engine.getSession();
String msg = "SSL summary for " + (incoming ? "incoming" : "outgoing") + " connection\n" +
"cipher = " + session.getCipherSuite() + "\n" +
- "protocol = " + session.getProtocol() + "\n" +
- IceInternal.Network.fdToString(fd);
+ "protocol = " + session.getProtocol() + "\n" + desc;
_logger.trace(_securityTraceCategory, msg);
}
@@ -956,7 +955,7 @@ class SSLEngine
return _communicator;
}
- void verifyPeer(NativeConnectionInfo info, java.nio.channels.SelectableChannel fd, String address)
+ void verifyPeer(String address, NativeConnectionInfo info, String desc)
{
//
// IceSSL.VerifyPeer is translated into the proper SSLEngine configuration
@@ -1108,8 +1107,7 @@ class SSLEngine
{
String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected:\n" +
"length of peer's certificate chain (" + info.nativeCerts.length + ") exceeds maximum of " +
- _verifyDepthMax + "\n" +
- IceInternal.Network.fdToString(fd);
+ _verifyDepthMax + "\n" + desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
@@ -1119,10 +1117,9 @@ class SSLEngine
throw ex;
}
- if(!_trustManager.verify(info))
+ if(!_trustManager.verify(info, desc))
{
- String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by trust manager\n" +
- IceInternal.Network.fdToString(fd);
+ String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by trust manager\n" + desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
@@ -1135,7 +1132,7 @@ class SSLEngine
if(_verifier != null && !_verifier.verify(info))
{
String msg = (info.incoming ? "incoming" : "outgoing") + " connection rejected by certificate verifier\n" +
- IceInternal.Network.fdToString(fd);
+ desc;
if(_securityTraceLevel >= 1)
{
_logger.trace(_securityTraceCategory, msg);
diff --git a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java
index c1a3277a511..20caf5de188 100644
--- a/java/src/Ice/src/main/java/IceSSL/TransceiverI.java
+++ b/java/src/Ice/src/main/java/IceSSL/TransceiverI.java
@@ -13,30 +13,51 @@ import java.nio.*;
import javax.net.ssl.*;
import javax.net.ssl.SSLEngineResult.*;
-final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTransceiverDelegate
+final class TransceiverI implements IceInternal.Transceiver
{
@Override
public java.nio.channels.SelectableChannel fd()
{
- return _stream.fd();
+ return _delegate.fd();
}
@Override
public void setReadyCallback(IceInternal.ReadyCallback callback)
{
_readyCallback = callback;
+ _delegate.setReadyCallback(callback);
}
@Override
public int initialize(IceInternal.Buffer readBuffer, IceInternal.Buffer writeBuffer)
{
- int status = _stream.connect(readBuffer, writeBuffer);
- if(status != IceInternal.SocketOperation.None)
+ if(!_isConnected)
{
- return status;
+ int status = _delegate.initialize(readBuffer, writeBuffer);
+ if(status != IceInternal.SocketOperation.None)
+ {
+ return status;
+ }
+ _isConnected = true;
+
+ Ice.IPConnectionInfo ipInfo = null;
+ for(Ice.ConnectionInfo p = _delegate.getInfo(); p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ ipInfo = (Ice.IPConnectionInfo)p;
+ }
+ }
+ final String host = _incoming ? (ipInfo != null ? ipInfo.remoteAddress : "") : _host;
+ final int port = ipInfo != null ? ipInfo.remotePort : -1;
+ _engine = _instance.createSSLEngine(_incoming, host, port);
+ _appInput = ByteBuffer.allocateDirect(_engine.getSession().getApplicationBufferSize() * 2);
+ int bufSize = _engine.getSession().getPacketBufferSize() * 2;
+ _netInput = new IceInternal.Buffer(ByteBuffer.allocateDirect(bufSize * 2));
+ _netOutput = new IceInternal.Buffer(ByteBuffer.allocateDirect(bufSize * 2));
}
- status = handshakeNonBlocking();
+ int status = handshakeNonBlocking();
if(status != IceInternal.SocketOperation.None)
{
return status;
@@ -45,11 +66,11 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
// Additional verification.
//
- _instance.verifyPeer((NativeConnectionInfo)getInfo(), _stream.fd(), _host);
+ _instance.verifyPeer(_host, (NativeConnectionInfo)getInfo(), _delegate.toString());
if(_instance.securityTraceLevel() >= 1)
{
- _instance.traceConnection(_stream.fd(), _engine, _incoming);
+ _instance.traceConnection(_delegate.toString(), _engine, _incoming);
}
return IceInternal.SocketOperation.None;
}
@@ -65,7 +86,7 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public void close()
{
- if(_stream.isConnected())
+ if(_isConnected)
{
try
{
@@ -73,10 +94,10 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// Send the close_notify message.
//
_engine.closeOutbound();
- _netOutput.clear();
+ _netOutput.b.clear();
while(!_engine.isOutboundDone())
{
- _engine.wrap(_emptyBuffer, _netOutput);
+ _engine.wrap(_emptyBuffer, _netOutput.b);
try
{
//
@@ -120,7 +141,7 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
}
- _stream.close();
+ _delegate.close();
}
@Override
@@ -133,9 +154,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public int write(IceInternal.Buffer buf)
{
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- return _stream.write(buf);
+ return _delegate.write(buf);
}
int status = writeNonBlocking(buf.b);
@@ -146,13 +167,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public int read(IceInternal.Buffer buf)
{
- _readyCallback.ready(IceInternal.SocketOperation.Read, false);
-
- if(!_stream.isConnected())
+ if(!_isConnected)
{
- return _stream.read(buf);
+ return _delegate.read(buf);
}
+ _readyCallback.ready(IceInternal.SocketOperation.Read, false);
+
//
// Try to satisfy the request from data we've already decrypted.
//
@@ -167,9 +188,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
{
while(buf.b.hasRemaining())
{
- _netInput.flip();
- SSLEngineResult result = _engine.unwrap(_netInput, _appInput);
- _netInput.compact();
+ _netInput.b.flip();
+ SSLEngineResult result = _engine.unwrap(_netInput.b, _appInput);
+ _netInput.b.compact();
Status status = result.getStatus();
assert status != Status.BUFFER_OVERFLOW;
@@ -180,11 +201,12 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
// Android API 21 SSLEngine doesn't report underflow, so look at the absence of
// network data and application data to signal a network read.
- else if(status == Status.BUFFER_UNDERFLOW || (_appInput.position() == 0 && _netInput.position() == 0))
+ else if(status == Status.BUFFER_UNDERFLOW || (_appInput.position() == 0 && _netInput.b.position() == 0))
{
- if(_stream.read(_netInput) == 0)
+ int s = _delegate.read(_netInput);
+ if(s != IceInternal.SocketOperation.None && _netInput.b.position() == 0)
{
- return IceInternal.SocketOperation.Read;
+ return s;
}
continue;
}
@@ -196,9 +218,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// that the SSLEngine has no buffered data (Android R21 and greater only).
if(_appInput.position() == 0)
{
- _netInput.flip();
- _engine.unwrap(_netInput, _appInput);
- _netInput.compact();
+ _netInput.b.flip();
+ _engine.unwrap(_netInput.b, _appInput);
+ _netInput.b.compact();
// Don't check the status here since we may have already filled
// the buffer with a complete request which must be processed.
@@ -212,7 +234,7 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
// Indicate whether more data is available.
//
- if(_netInput.position() > 0 || _appInput.position() > 0)
+ if(_netInput.b.position() > 0 || _appInput.position() > 0)
{
_readyCallback.ready(IceInternal.SocketOperation.Read, true);
}
@@ -223,13 +245,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
@Override
public String protocol()
{
- return _instance.protocol();
+ return _delegate.protocol();
}
@Override
public String toString()
{
- return _stream.toString();
+ return _delegate.toString();
}
@Override
@@ -242,81 +264,11 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
public Ice.ConnectionInfo getInfo()
{
NativeConnectionInfo info = new NativeConnectionInfo();
- info.nativeCerts = fillConnectionInfo(info);
- return info;
- }
-
- @Override
- public Ice.ConnectionInfo getWSInfo(java.util.Map<String, String> headers)
- {
- WSSNativeConnectionInfo info = new WSSNativeConnectionInfo();
- info.nativeCerts = fillConnectionInfo(info);
- info.headers = headers; // Provided header is a copy so no need to clone here.
- return info;
- }
-
- @Override
- public void setBufferSize(int rcvSize, int sndSize)
- {
- _stream.setBufferSize(rcvSize, sndSize);
- }
-
- @Override
- public void checkSendSize(IceInternal.Buffer buf)
- {
- }
-
- TransceiverI(Instance instance, javax.net.ssl.SSLEngine engine, IceInternal.StreamSocket stream, String hostOrAdapterName,
- boolean incoming)
- {
- _instance = instance;
- _engine = engine;
- _appInput = ByteBuffer.allocateDirect(engine.getSession().getApplicationBufferSize() * 2);
- _netInput = ByteBuffer.allocateDirect(engine.getSession().getPacketBufferSize() * 2);
- _netOutput = ByteBuffer.allocateDirect(engine.getSession().getPacketBufferSize() * 2);
- _stream = stream;
- _incoming = incoming;
- if(_incoming)
- {
- _adapterName = hostOrAdapterName;
- }
- else
- {
- _host = hostOrAdapterName;
- }
- }
-
- private java.security.cert.Certificate[] fillConnectionInfo(ConnectionInfo info)
- {
- //
- // This can only be called on an open transceiver.
- //
- java.security.cert.Certificate[] nativeCerts = null;
- if(_stream.fd() != null)
+ info.underlying = _delegate.getInfo();
+ info.incoming = _incoming;
+ info.adapterName = _adapterName;
+ if(_engine != null)
{
- java.net.Socket socket = _stream.fd().socket();
- //
- // On some platforms (e.g., early Android releases), sockets don't
- // correctly return address information.
- //
- if(socket.getLocalAddress() != null)
- {
- info.localAddress = socket.getLocalAddress().getHostAddress();
- info.localPort = socket.getLocalPort();
- }
-
- if(socket.getInetAddress() != null)
- {
- info.remoteAddress = socket.getInetAddress().getHostAddress();
- info.remotePort = socket.getPort();
- }
-
- if(!socket.isClosed())
- {
- info.rcvSize = IceInternal.Network.getRecvBufferSize(_stream.fd());
- info.sndSize = IceInternal.Network.getSendBufferSize(_stream.fd());
- }
-
SSLSession session = _engine.getSession();
info.cipher = session.getCipherSuite();
try
@@ -324,9 +276,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
java.security.cert.Certificate[] pcerts = session.getPeerCertificates();
java.security.cert.Certificate[] vcerts = _instance.engine().getVerifiedCertificateChain(pcerts);
info.verified = vcerts != null;
- nativeCerts = vcerts != null ? vcerts : pcerts;
+ info.nativeCerts = vcerts != null ? vcerts : pcerts;
java.util.ArrayList<String> certs = new java.util.ArrayList<String>();
- for(java.security.cert.Certificate c : nativeCerts)
+ for(java.security.cert.Certificate c : info.nativeCerts)
{
StringBuilder s = new StringBuilder("-----BEGIN CERTIFICATE-----\n");
s.append(IceUtilInternal.Base64.encode(c.getEncoded()));
@@ -343,9 +295,34 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
{
}
}
- info.adapterName = _adapterName;
- info.incoming = _incoming;
- return nativeCerts;
+ return info;
+ }
+
+ @Override
+ public void setBufferSize(int rcvSize, int sndSize)
+ {
+ _delegate.setBufferSize(rcvSize, sndSize);
+ }
+
+ @Override
+ public void checkSendSize(IceInternal.Buffer buf)
+ {
+ _delegate.checkSendSize(buf);
+ }
+
+ TransceiverI(Instance instance, IceInternal.Transceiver delegate, String hostOrAdapterName, boolean incoming)
+ {
+ _instance = instance;
+ _delegate = delegate;
+ _incoming = incoming;
+ if(_incoming)
+ {
+ _adapterName = hostOrAdapterName;
+ }
+ else
+ {
+ _host = hostOrAdapterName;
+ }
}
private int handshakeNonBlocking()
@@ -375,9 +352,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
case NEED_UNWRAP:
{
- if(_netInput.position() == 0 && _stream.read(_netInput) == 0)
+ if(_netInput.b.position() == 0)
{
- return IceInternal.SocketOperation.Read;
+ int s = _delegate.read(_netInput);
+ if(s != IceInternal.SocketOperation.None && _netInput.b.position() == 0)
+ {
+ return s;
+ }
}
//
@@ -385,9 +366,9 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// the _netInput buffer to satisfy the engine. If not, the engine
// responds with BUFFER_UNDERFLOW and we'll read from the socket.
//
- _netInput.flip();
- result = _engine.unwrap(_netInput, _appInput);
- _netInput.compact();
+ _netInput.b.flip();
+ result = _engine.unwrap(_netInput.b, _appInput);
+ _netInput.b.compact();
//
// FINISHED is only returned from wrap or unwrap, not from engine.getHandshakeResult().
//
@@ -402,9 +383,11 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
case BUFFER_UNDERFLOW:
{
assert(status == javax.net.ssl.SSLEngineResult.HandshakeStatus.NEED_UNWRAP);
- if(_stream.read(_netInput) == 0)
+ int position = _netInput.b.position();
+ int s = _delegate.read(_netInput);
+ if(s != IceInternal.SocketOperation.None && _netInput.b.position() == position)
{
- return IceInternal.SocketOperation.Read;
+ return s;
}
break;
}
@@ -424,10 +407,14 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
// The engine needs to send a message.
//
- result = _engine.wrap(_emptyBuffer, _netOutput);
- if(result.bytesProduced() > 0 && !flushNonBlocking())
+ result = _engine.wrap(_emptyBuffer, _netOutput.b);
+ if(result.bytesProduced() > 0)
{
- return IceInternal.SocketOperation.Write;
+ int s = flushNonBlocking();
+ if(s != IceInternal.SocketOperation.None)
+ {
+ return s;
+ }
}
//
@@ -473,19 +460,19 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
//
try
{
- while(buf.hasRemaining() || _netOutput.position() > 0)
+ while(buf.hasRemaining() || _netOutput.b.position() > 0)
{
if(buf.hasRemaining())
{
//
// Encrypt the buffer.
//
- SSLEngineResult result = _engine.wrap(buf, _netOutput);
+ SSLEngineResult result = _engine.wrap(buf, _netOutput.b);
switch(result.getStatus())
{
case BUFFER_OVERFLOW:
//
- // Need to make room in _netOutput.
+ // Need to make room in _netOutput.b.
//
break;
case BUFFER_UNDERFLOW:
@@ -503,9 +490,13 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
// all of _netOutput, or until flushNonBlocking indicates that it cannot write
// (i.e., by returning SocketOperation.Write).
//
- if(_netOutput.position() > 0 && !flushNonBlocking())
+ if(_netOutput.b.position() > 0)
{
- return IceInternal.SocketOperation.Write;
+ int s = flushNonBlocking();
+ if(s != IceInternal.SocketOperation.None)
+ {
+ return s;
+ }
}
}
}
@@ -514,33 +505,29 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
throw new Ice.SecurityException("IceSSL: error while encoding message", ex);
}
- assert(_netOutput.position() == 0);
+ assert(_netOutput.b.position() == 0);
return IceInternal.SocketOperation.None;
}
- private boolean flushNonBlocking()
+ private int flushNonBlocking()
{
- _netOutput.flip();
+ _netOutput.b.flip();
try
{
- _stream.write(_netOutput);
+ int s = _delegate.write(_netOutput);
+ if(s != IceInternal.SocketOperation.None)
+ {
+ _netOutput.b.compact();
+ return s;
+ }
}
catch(Ice.SocketException ex)
{
throw new Ice.ConnectionLostException(ex);
}
-
- if(_netOutput.hasRemaining())
- {
- _netOutput.compact();
- return false;
- }
- else
- {
- _netOutput.clear();
- return true;
- }
+ _netOutput.b.clear();
+ return IceInternal.SocketOperation.None;
}
private void fill(ByteBuffer buf)
@@ -586,15 +573,16 @@ final class TransceiverI implements IceInternal.Transceiver, IceInternal.WSTrans
}
private Instance _instance;
- private IceInternal.StreamSocket _stream;
+ private IceInternal.Transceiver _delegate;
private javax.net.ssl.SSLEngine _engine;
private String _host = "";
private String _adapterName = "";
private boolean _incoming;
private IceInternal.ReadyCallback _readyCallback;
+ private boolean _isConnected = false;
private ByteBuffer _appInput; // Holds clear-text data to be read by the application.
- private ByteBuffer _netInput; // Holds encrypted data read from the socket.
- private ByteBuffer _netOutput; // Holds encrypted data to be written to the socket.
+ private IceInternal.Buffer _netInput; // Holds encrypted data read from the socket.
+ private IceInternal.Buffer _netOutput; // Holds encrypted data to be written to the socket.
private static ByteBuffer _emptyBuffer = ByteBuffer.allocate(0); // Used during handshaking.
}
diff --git a/java/src/Ice/src/main/java/IceSSL/TrustManager.java b/java/src/Ice/src/main/java/IceSSL/TrustManager.java
index 4dde5cb6fce..ba17851dee8 100644
--- a/java/src/Ice/src/main/java/IceSSL/TrustManager.java
+++ b/java/src/Ice/src/main/java/IceSSL/TrustManager.java
@@ -55,7 +55,7 @@ class TrustManager
}
boolean
- verify(NativeConnectionInfo info)
+ verify(NativeConnectionInfo info, String desc)
{
java.util.List<java.util.List<java.util.List<RFC2253.RDNPair> > >
reject = new java.util.LinkedList<java.util.List<java.util.List<RFC2253.RDNPair> > >(),
@@ -143,15 +143,12 @@ class TrustManager
_communicator.getLogger().trace("Security", "trust manager evaluating client:\n" +
"subject = " + subjectName + "\n" +
"adapter = " + info.adapterName + "\n" +
- "local addr = " + info.localAddress + ":" + info.localPort + "\n" +
- "remote addr = " + info.remoteAddress + ":" + info.remotePort);
+ desc);
}
else
{
_communicator.getLogger().trace("Security", "trust manager evaluating server:\n" +
- "subject = " + subjectName + "\n" +
- "local addr = " + info.localAddress + ":" + info.localPort + "\n" +
- "remote addr = " + info.remoteAddress + ":" + info.remotePort);
+ "subject = " + subjectName + "\n" + desc);
}
}
java.util.List<RFC2253.RDNPair> dn = RFC2253.parseStrict(subjectName);
diff --git a/java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java b/java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java
deleted file mode 100644
index 6c165f7f0f0..00000000000
--- a/java/src/Ice/src/main/java/IceSSL/WSSNativeConnectionInfo.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-package IceSSL;
-
-/**
- *
- * This class is a native extension of the Slice local class
- * IceSSL::WSSConnectionInfo. It provides access to the native
- * Java certificates.
- *
- **/
-public class WSSNativeConnectionInfo extends WSSConnectionInfo
-{
- /**
- * The certificate chain. This may be null if the peer did not
- * supply a certificate. The peer's certificate (if any) is the
- * first one in the chain.
- **/
- public java.security.cert.Certificate[] nativeCerts;
-}
diff --git a/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java b/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java
index 4f9fce5ec3a..5ffc5141907 100644
--- a/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java
+++ b/java/src/IceBT/src/main/java/IceBT/EndpointFactoryI.java
@@ -50,9 +50,9 @@ final class EndpointFactoryI implements IceInternal.EndpointFactory
}
@Override
- public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance instance)
+ public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst, IceInternal.EndpointFactory del)
{
- return new EndpointFactoryI(new Instance(_instance.communicator(), instance.type(), instance.protocol()));
+ return new EndpointFactoryI(new Instance(_instance.communicator(), inst.type(), inst.protocol()));
}
private Instance _instance;
diff --git a/java/src/IceBT/src/main/java/IceBT/EndpointI.java b/java/src/IceBT/src/main/java/IceBT/EndpointI.java
index e9db453200f..7576f458fae 100644
--- a/java/src/IceBT/src/main/java/IceBT/EndpointI.java
+++ b/java/src/IceBT/src/main/java/IceBT/EndpointI.java
@@ -71,17 +71,15 @@ final class EndpointI extends IceInternal.EndpointI
}
@Override
- public void streamWrite(Ice.OutputStream s)
+ public void streamWriteImpl(Ice.OutputStream s)
{
//
// _name and _channel are not marshaled.
//
- s.startEncapsulation();
s.writeString(_addr);
s.writeString(_uuid.toString());
s.writeInt(_timeout);
s.writeBool(_compress);
- s.endEncapsulation();
}
@Override
diff --git a/java/src/IceBT/src/main/java/IceBT/PluginI.java b/java/src/IceBT/src/main/java/IceBT/PluginI.java
index 635071c17e4..b2d0f8b17cf 100644
--- a/java/src/IceBT/src/main/java/IceBT/PluginI.java
+++ b/java/src/IceBT/src/main/java/IceBT/PluginI.java
@@ -20,7 +20,7 @@ class PluginI implements Ice.Plugin
// in initialize, because the communicator may need to interpret
// proxies before the plug-in is fully initialized.
//
- EndpointFactoryI factory = new EndpointFactoryI(new Instance(communicator, EndpointType.value, "bt"));
+ EndpointFactoryI factory = new EndpointFactoryI(new Instance(communicator, Ice.BTEndpointType.value, "bt"));
facade.addEndpointFactory(factory);
}
diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
index 5c0e854c4e9..30d5e204a2d 100644
--- a/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
+++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/Coordinator.java
@@ -1498,32 +1498,45 @@ public class Coordinator
validDate = false;
}
+ String remoteAddress = null;
+ for(Ice.ConnectionInfo p = info.underlying; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ remoteAddress = ((Ice.IPConnectionInfo)p).remoteAddress;
+ break;
+ }
+ }
+
//
// Check server alternate names match the connection remote address
//
- try
+ if(remoteAddress != null)
{
- Collection<java.util.List<?>> altNames = cert.getSubjectAlternativeNames();
- if(altNames != null)
+ try
{
- for(java.util.List<?> l : altNames)
+ Collection<java.util.List<?>> altNames = cert.getSubjectAlternativeNames();
+ if(altNames != null)
{
- Integer kind = (Integer)l.get(0);
- if(kind != 2 && kind != 7)
- {
- continue;
- }
- if(info.remoteAddress.equalsIgnoreCase(l.get(1).toString()))
+ for(java.util.List<?> l : altNames)
{
- validAlternateName = true;
- break;
+ Integer kind = (Integer)l.get(0);
+ if(kind != 2 && kind != 7)
+ {
+ continue;
+ }
+ if(remoteAddress.equalsIgnoreCase(l.get(1).toString()))
+ {
+ validAlternateName = true;
+ break;
+ }
}
}
}
- }
- catch(java.security.cert.CertificateParsingException ex)
- {
- validAlternateName = false;
+ catch(java.security.cert.CertificateParsingException ex)
+ {
+ validAlternateName = false;
+ }
}
//
diff --git a/java/test/src/main/java/test/Ice/background/EndpointFactory.java b/java/test/src/main/java/test/Ice/background/EndpointFactory.java
index 518317bf406..279a7d9d6e3 100644
--- a/java/test/src/main/java/test/Ice/background/EndpointFactory.java
+++ b/java/test/src/main/java/test/Ice/background/EndpointFactory.java
@@ -58,7 +58,7 @@ final class EndpointFactory implements IceInternal.EndpointFactory
@Override
public IceInternal.EndpointFactory
- clone(IceInternal.ProtocolInstance instance)
+ clone(IceInternal.ProtocolInstance instance, IceInternal.EndpointFactory del)
{
return this;
}
diff --git a/java/test/src/main/java/test/Ice/background/EndpointI.java b/java/test/src/main/java/test/Ice/background/EndpointI.java
index 7f559d11950..eb51c2d26f9 100644
--- a/java/test/src/main/java/test/Ice/background/EndpointI.java
+++ b/java/test/src/main/java/test/Ice/background/EndpointI.java
@@ -35,12 +35,10 @@ final class EndpointI extends IceInternal.EndpointI
@Override
public void
- streamWrite(Ice.OutputStream s)
+ streamWriteImpl(Ice.OutputStream s)
{
- s.startEncapsulation();
s.writeShort(_endpoint.type());
_endpoint.streamWrite(s);
- s.endEncapsulation();
}
@Override
diff --git a/java/test/src/main/java/test/Ice/info/AllTests.java b/java/test/src/main/java/test/Ice/info/AllTests.java
index c23e53426ab..c2e3b3022f2 100644
--- a/java/test/src/main/java/test/Ice/info/AllTests.java
+++ b/java/test/src/main/java/test/Ice/info/AllTests.java
@@ -25,6 +25,32 @@ public class AllTests
}
}
+ private static Ice.TCPEndpointInfo
+ getTCPEndpointInfo(Ice.EndpointInfo info)
+ {
+ for(Ice.EndpointInfo p = info; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.TCPEndpointInfo)
+ {
+ return (Ice.TCPEndpointInfo)p;
+ }
+ }
+ return null;
+ }
+
+ private static Ice.TCPConnectionInfo
+ getTCPConnectionInfo(Ice.ConnectionInfo info)
+ {
+ for(Ice.ConnectionInfo p = info; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.TCPConnectionInfo)
+ {
+ return (Ice.TCPConnectionInfo)p;
+ }
+ }
+ return null;
+ }
+
public static void
allTests(Ice.Communicator communicator, PrintWriter out)
{
@@ -37,23 +63,23 @@ public class AllTests
"opaque -e 1.8 -t 100 -v ABCD");
Ice.Endpoint[] endps = p1.ice_getEndpoints();
-
-
- Ice.IPEndpointInfo ipEndpoint = (Ice.IPEndpointInfo)endps[0].getInfo();
- test(ipEndpoint.host.equals("tcphost"));
- test(ipEndpoint.port == 10000);
- test(ipEndpoint.timeout == 1200);
- test(ipEndpoint.sourceAddress.equals("10.10.10.10"));
- test(ipEndpoint.compress);
- test(!ipEndpoint.datagram());
- test(ipEndpoint.type() == Ice.TCPEndpointType.value && !ipEndpoint.secure() ||
- ipEndpoint.type() == IceSSL.EndpointType.value && ipEndpoint.secure() ||
- ipEndpoint.type() == Ice.WSEndpointType.value && !ipEndpoint.secure() ||
- ipEndpoint.type() == Ice.WSSEndpointType.value && ipEndpoint.secure());
- test(ipEndpoint.type() == Ice.TCPEndpointType.value && ipEndpoint instanceof Ice.TCPEndpointInfo ||
- ipEndpoint.type() == IceSSL.EndpointType.value && ipEndpoint instanceof IceSSL.EndpointInfo ||
- ipEndpoint.type() == Ice.WSEndpointType.value && ipEndpoint instanceof Ice.WSEndpointInfo ||
- ipEndpoint.type() == Ice.WSSEndpointType.value && ipEndpoint instanceof IceSSL.WSSEndpointInfo);
+ Ice.EndpointInfo info = endps[0].getInfo();
+ Ice.TCPEndpointInfo tcpEndpoint = (Ice.TCPEndpointInfo)getTCPEndpointInfo(info);
+ test(tcpEndpoint.host.equals("tcphost"));
+ test(tcpEndpoint.port == 10000);
+ test(tcpEndpoint.timeout == 1200);
+ test(tcpEndpoint.sourceAddress.equals("10.10.10.10"));
+ test(tcpEndpoint.compress);
+ test(!tcpEndpoint.datagram());
+ test(tcpEndpoint.type() == Ice.TCPEndpointType.value && !tcpEndpoint.secure() ||
+ tcpEndpoint.type() == Ice.SSLEndpointType.value && tcpEndpoint.secure() ||
+ tcpEndpoint.type() == Ice.WSEndpointType.value && !tcpEndpoint.secure() ||
+ tcpEndpoint.type() == Ice.WSSEndpointType.value && tcpEndpoint.secure());
+
+ test(tcpEndpoint.type() == Ice.TCPEndpointType.value && info instanceof Ice.TCPEndpointInfo ||
+ tcpEndpoint.type() == Ice.SSLEndpointType.value && info instanceof IceSSL.EndpointInfo ||
+ tcpEndpoint.type() == Ice.WSEndpointType.value && info instanceof Ice.WSEndpointInfo ||
+ tcpEndpoint.type() == Ice.WSSEndpointType.value && info instanceof Ice.WSEndpointInfo);
Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endps[1].getInfo();
test(udpEndpoint.host.equals("udphost"));
@@ -84,12 +110,12 @@ public class AllTests
Ice.Endpoint[] publishedEndpoints = adapter.getPublishedEndpoints();
test(java.util.Arrays.equals(endpoints, publishedEndpoints));
- Ice.IPEndpointInfo ipEndpoint = (Ice.IPEndpointInfo)endpoints[0].getInfo();
- test(ipEndpoint.type() == Ice.TCPEndpointType.value || ipEndpoint.type() == IceSSL.EndpointType.value ||
- ipEndpoint.type() == Ice.WSEndpointType.value || ipEndpoint.type() == Ice.WSSEndpointType.value);
- test(ipEndpoint.host.equals(defaultHost));
- test(ipEndpoint.port > 0);
- test(ipEndpoint.timeout == 15000);
+ Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo());
+ test(tcpEndpoint.type() == Ice.TCPEndpointType.value || tcpEndpoint.type() == Ice.SSLEndpointType.value ||
+ tcpEndpoint.type() == Ice.WSEndpointType.value || tcpEndpoint.type() == Ice.WSSEndpointType.value);
+ test(tcpEndpoint.host.equals(defaultHost));
+ test(tcpEndpoint.port > 0);
+ test(tcpEndpoint.timeout == 15000);
Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endpoints[1].getInfo();
test(udpEndpoint.host.equals(defaultHost));
@@ -109,13 +135,13 @@ public class AllTests
for(Ice.Endpoint endpoint : endpoints)
{
- ipEndpoint = (Ice.IPEndpointInfo)endpoint.getInfo();
- test(ipEndpoint.port == 12020);
+ tcpEndpoint = getTCPEndpointInfo(endpoint.getInfo());
+ test(tcpEndpoint.port == 12020);
}
- ipEndpoint = (Ice.IPEndpointInfo)publishedEndpoints[0].getInfo();
- test(ipEndpoint.host.equals("127.0.0.1"));
- test(ipEndpoint.port == 12020);
+ tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo());
+ test(tcpEndpoint.host.equals("127.0.0.1"));
+ test(tcpEndpoint.port == 12020);
adapter.destroy();
}
@@ -128,13 +154,13 @@ public class AllTests
out.flush();
{
Ice.EndpointInfo info = base.ice_getConnection().getEndpoint().getInfo();
- Ice.IPEndpointInfo ipinfo = (Ice.IPEndpointInfo)info;
- test(ipinfo.port == 12010);
- test(!ipinfo.compress);
- test(ipinfo.host.equals(defaultHost));
+ Ice.TCPEndpointInfo tcpinfo = getTCPEndpointInfo(info);
+ test(tcpinfo.port == 12010);
+ test(!tcpinfo.compress);
+ test(tcpinfo.host.equals(defaultHost));
java.util.Map<String, String> ctx = testIntf.getEndpointInfoAsContext();
- test(ctx.get("host").equals(ipinfo.host));
+ test(ctx.get("host").equals(tcpinfo.host));
test(ctx.get("compress").equals("false"));
int port = Integer.parseInt(ctx.get("port"));
test(port > 0);
@@ -152,7 +178,7 @@ public class AllTests
Ice.Connection connection = base.ice_getConnection();
connection.setBufferSize(1024, 2048);
- Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)connection.getInfo();
+ Ice.TCPConnectionInfo info = getTCPConnectionInfo(connection.getInfo());
test(!info.incoming);
test(info.adapterName.length() == 0);
test(info.localPort > 0);
@@ -175,15 +201,7 @@ public class AllTests
if(base.ice_getConnection().type().equals("ws") || base.ice_getConnection().type().equals("wss"))
{
- java.util.Map<String, String> headers;
- if(info instanceof Ice.WSConnectionInfo)
- {
- headers = ((Ice.WSConnectionInfo)info).headers;
- }
- else
- {
- headers = ((IceSSL.WSSConnectionInfo)info).headers;
- }
+ java.util.Map<String, String> headers = ((Ice.WSConnectionInfo)connection.getInfo()).headers;
test(headers.get("Upgrade").equals("websocket"));
test(headers.get("Connection").equals("Upgrade"));
test(headers.get("Sec-WebSocket-Protocol").equals("ice.zeroc.com"));
@@ -199,18 +217,18 @@ public class AllTests
connection = base.ice_datagram().ice_getConnection();
connection.setBufferSize(2048, 1024);
- info = (Ice.IPConnectionInfo)connection.getInfo();
- test(!info.incoming);
- test(info.adapterName.length() == 0);
- test(info.localPort > 0);
- test(info.remotePort == 12010);
+ Ice.UDPConnectionInfo udpinfo = (Ice.UDPConnectionInfo)connection.getInfo();
+ test(!udpinfo.incoming);
+ test(udpinfo.adapterName.length() == 0);
+ test(udpinfo.localPort > 0);
+ test(udpinfo.remotePort == 12010);
if(defaultHost.equals("127.0.0.1"))
{
- test(info.remoteAddress.equals(defaultHost));
- test(info.localAddress.equals(defaultHost));
+ test(udpinfo.remoteAddress.equals(defaultHost));
+ test(udpinfo.localAddress.equals(defaultHost));
}
- test(info.rcvSize >= 2048);
- test(info.sndSize >= 1024);
+ test(udpinfo.rcvSize >= 2048);
+ test(udpinfo.sndSize >= 1024);
}
out.println("ok");
diff --git a/java/test/src/main/java/test/Ice/info/TestI.java b/java/test/src/main/java/test/Ice/info/TestI.java
index 998584c6ac2..71daea00326 100644
--- a/java/test/src/main/java/test/Ice/info/TestI.java
+++ b/java/test/src/main/java/test/Ice/info/TestI.java
@@ -12,6 +12,32 @@ import test.Ice.info.Test._TestIntfDisp;
public class TestI extends _TestIntfDisp
{
+ private static Ice.IPEndpointInfo
+ getIPEndpointInfo(Ice.EndpointInfo info)
+ {
+ for(Ice.EndpointInfo p = info; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPEndpointInfo)
+ {
+ return (Ice.IPEndpointInfo)p;
+ }
+ }
+ return null;
+ }
+
+ private static Ice.IPConnectionInfo
+ getIPConnectionInfo(Ice.ConnectionInfo info)
+ {
+ for(Ice.ConnectionInfo p = info; p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ return (Ice.IPConnectionInfo)p;
+ }
+ }
+ return null;
+ }
+
TestI()
{
}
@@ -33,7 +59,7 @@ public class TestI extends _TestIntfDisp
ctx.put("secure", info.datagram() ? "true" : "false");
ctx.put("type", Integer.toString(info.type()));
- Ice.IPEndpointInfo ipinfo = (Ice.IPEndpointInfo)info;
+ Ice.IPEndpointInfo ipinfo = getIPEndpointInfo(info);
ctx.put("host", ipinfo.host);
ctx.put("port", Integer.toString(ipinfo.port));
@@ -55,7 +81,7 @@ public class TestI extends _TestIntfDisp
ctx.put("adapterName", info.adapterName);
ctx.put("incoming", info.incoming ? "true" : "false");
- Ice.IPConnectionInfo ipinfo = (Ice.IPConnectionInfo)info;
+ Ice.IPConnectionInfo ipinfo = getIPConnectionInfo(info);
ctx.put("localAddress", ipinfo.localAddress);
ctx.put("localPort", Integer.toString(ipinfo.localPort));
ctx.put("remoteAddress", ipinfo.remoteAddress);
@@ -70,15 +96,6 @@ public class TestI extends _TestIntfDisp
}
}
- if(info instanceof IceSSL.WSSConnectionInfo)
- {
- IceSSL.WSSConnectionInfo wssinfo = (IceSSL.WSSConnectionInfo)info;
- for(java.util.Map.Entry<String, String> e : wssinfo.headers.entrySet())
- {
- ctx.put("ws." + e.getKey(), e.getValue());
- }
- }
-
return ctx;
}
}
diff --git a/java/test/src/main/java/test/Ice/metrics/AllTests.java b/java/test/src/main/java/test/Ice/metrics/AllTests.java
index 7e837c75bd8..acda4ab09a3 100644
--- a/java/test/src/main/java/test/Ice/metrics/AllTests.java
+++ b/java/test/src/main/java/test/Ice/metrics/AllTests.java
@@ -461,7 +461,7 @@ public class AllTests
test(view.get("Connection").length == 1 && view.get("Connection")[0].current == 1 &&
view.get("Connection")[0].total == 1);
}
- test(view.get("Thread").length == 1 && view.get("Thread")[0].current == threadCount &&
+ test(view.get("Thread").length == 1 && view.get("Thread")[0].current == threadCount &&
view.get("Thread")[0].total == threadCount);
out.println("ok");
@@ -520,6 +520,17 @@ public class AllTests
out.println("ok");
+ String endpoint = communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp") +
+ " -h 127.0.0.1 -p 12010";
+ String type = "";
+ String isSecure = "";
+ if(!collocated)
+ {
+ Ice.EndpointInfo endpointInfo = metrics.ice_getConnection().getEndpoint().getInfo();
+ type = Short.toString(endpointInfo.type());
+ isSecure = endpointInfo.secure() ? "true": "false";
+ }
+
Map<String, IceMX.Metrics> map;
if(!collocated)
@@ -662,11 +673,11 @@ public class AllTests
testAttribute(clientMetrics, clientProps, update, "Connection", "parent", "Communicator", out);
//testAttribute(clientMetrics, clientProps, update, "Connection", "id", "");
testAttribute(clientMetrics, clientProps, update, "Connection", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 500", out);
+ endpoint + " -t 500", out);
- testAttribute(clientMetrics, clientProps, update, "Connection", "endpointType", "1", out);
+ testAttribute(clientMetrics, clientProps, update, "Connection", "endpointType", type, out);
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsDatagram", "false", out);
- testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsSecure", "false", out);
+ testAttribute(clientMetrics, clientProps, update, "Connection", "endpointIsSecure", isSecure, out);
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointTimeout", "500", out);
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointCompress", "false", out);
testAttribute(clientMetrics, clientProps, update, "Connection", "endpointHost", "127.0.0.1", out);
@@ -724,17 +735,17 @@ public class AllTests
checkFailure(clientMetrics, "ConnectionEstablishment", m1.id, "::Ice::ConnectTimeoutException", 2, out);
Connect c = new Connect(metrics);
- testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "parent", "Communicator", c,
+ testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "parent", "Communicator", c,
out);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "id", "127.0.0.1:12010", c,
out);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 60000", c, out);
+ endpoint + " -t 60000", c, out);
- testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointType", "1", c, out);
- testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "false",
+ testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointType", type, c, out);
+ testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsDatagram", "false",
c, out);
- testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", "false", c,
+ testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointIsSecure", isSecure, c,
out);
testAttribute(clientMetrics, clientProps, update, "ConnectionEstablishment", "endpointTimeout", "60000", c,
out);
@@ -759,7 +770,7 @@ public class AllTests
test(clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup").length == 1);
m1 = clientMetrics.getMetricsView("View", timestamp).get("EndpointLookup")[0];
- test(m1.current <= 1 && m1.total == 1 && m1.id.equals("tcp -h localhost -p 12010 -t infinite"));
+ test(m1.current <= 1 && m1.total == 1 && m1.id.equals(prx.ice_getConnection().getEndpoint().toString()));
prx.ice_getConnection().close(false);
@@ -794,13 +805,13 @@ public class AllTests
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "parent", "Communicator", c, out);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "id",
- "tcp -h localhost -p 12010 -t infinite", c, out);
+ prx.ice_getConnection().getEndpoint().toString(), c, out);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpoint",
- "tcp -h localhost -p 12010 -t infinite", c, out);
+ prx.ice_getConnection().getEndpoint().toString(), c, out);
- testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", "1", c, out);
+ testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointType", type, c, out);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsDatagram", "false", c, out);
- testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsSecure", "false", c, out);
+ testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointIsSecure", isSecure, c, out);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointTimeout", "-1", c, out);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointCompress", "false", c, out);
testAttribute(clientMetrics, clientProps, update, "EndpointLookup", "endpointHost", "localhost", c, out);
@@ -893,12 +904,12 @@ public class AllTests
if(!collocated)
{
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 60000", op, out);
+ endpoint + " -t 60000", op, out);
//testAttribute(serverMetrics, serverProps, update, "Dispatch", "connection", "", op);
- testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointType", "1", op, out);
+ testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointType", type, op, out);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsDatagram", "false", op, out);
- testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsSecure", "false", op, out);
+ testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointIsSecure", isSecure, op, out);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointTimeout", "60000", op, out);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointCompress", "false", op, out);
testAttribute(serverMetrics, serverProps, update, "Dispatch", "endpointHost", "127.0.0.1", op, out);
@@ -1109,7 +1120,7 @@ public class AllTests
testAttribute(clientMetrics, clientProps, update, "Invocation", "encoding", "1.1", op, out);
testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "twoway", op, out);
testAttribute(clientMetrics, clientProps, update, "Invocation", "proxy",
- "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 60000", op, out);
+ "metrics -t -e 1.1:" + endpoint + " -t 60000", op, out);
testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry1", "test", op, out);
testAttribute(clientMetrics, clientProps, update, "Invocation", "context.entry2", "", op, out);
@@ -1122,7 +1133,7 @@ public class AllTests
props.put("IceMX.Metrics.View.Map.Invocation.GroupBy", "operation");
props.put("IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy", "localPort");
updateProps(clientProps, serverProps, update, props, "Invocation");
-
+
MetricsPrx metricsOneway = (MetricsPrx)metrics.ice_oneway();
metricsOneway.op();
metricsOneway.end_op(metricsOneway.begin_op());
@@ -1147,7 +1158,7 @@ public class AllTests
props.put("IceMX.Metrics.View.Map.Invocation.GroupBy", "operation");
props.put("IceMX.Metrics.View.Map.Invocation.Map.Remote.GroupBy", "localPort");
updateProps(clientProps, serverProps, update, props, "Invocation");
-
+
MetricsPrx metricsBatchOneway = (MetricsPrx)metrics.ice_batchOneway();
metricsBatchOneway.op();
metricsBatchOneway.end_op(metricsBatchOneway.begin_op());
@@ -1160,8 +1171,8 @@ public class AllTests
test(im1.current == 0 && im1.total == 2 && im1.failures == 0 && im1.retry == 0);
test(im1.remotes.length == 0);
- testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "batch-oneway",
- new InvokeOp(metricsBatchOneway), out);
+ testAttribute(clientMetrics, clientProps, update, "Invocation", "mode", "batch-oneway",
+ new InvokeOp(metricsBatchOneway), out);
out.println("ok");
diff --git a/java/test/src/main/java/test/Ice/networkProxy/AllTests.java b/java/test/src/main/java/test/Ice/networkProxy/AllTests.java
index 94291ce3132..4ec21083e4a 100644
--- a/java/test/src/main/java/test/Ice/networkProxy/AllTests.java
+++ b/java/test/src/main/java/test/Ice/networkProxy/AllTests.java
@@ -48,7 +48,14 @@ public class AllTests
out.print("testing connection information... ");
out.flush();
{
- Ice.IPConnectionInfo info = (Ice.IPConnectionInfo)test.ice_getConnection().getInfo();
+ Ice.IPConnectionInfo info = null;
+ for(Ice.ConnectionInfo p = test.ice_getConnection().getInfo(); p != null; p = p.underlying)
+ {
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ info = (Ice.IPConnectionInfo)p;
+ }
+ }
test(info.remotePort == 12030 || info.remotePort == 12031); // make sure we are connected to the proxy port.
}
out.println("ok");
diff --git a/java/test/src/main/java/test/IceSSL/configuration/AllTests.java b/java/test/src/main/java/test/IceSSL/configuration/AllTests.java
index 6a8df8f8030..d4d89c9f61e 100644
--- a/java/test/src/main/java/test/IceSSL/configuration/AllTests.java
+++ b/java/test/src/main/java/test/IceSSL/configuration/AllTests.java
@@ -2253,11 +2253,11 @@ public class AllTests
initData.properties.setProperty("IceSSL.UsePlatformCAs", "1");
comm = Ice.Util.initialize(initData);
p = comm.stringToProxy("dummy:wss -h demo.zeroc.com -p 5064");
- IceSSL.WSSConnectionInfo info;
try
{
- info = (IceSSL.WSSConnectionInfo)p.ice_getConnection().getInfo();
- test(info.verified);
+ Ice.WSConnectionInfo info = (Ice.WSConnectionInfo)p.ice_getConnection().getInfo();
+ IceSSL.ConnectionInfo sslinfo = (IceSSL.ConnectionInfo)info.underlying;
+ test(sslinfo.verified);
}
catch(Ice.LocalException ex)
{
diff --git a/js/Makefile b/js/Makefile
index 356df4acb72..89f3c7383e4 100644
--- a/js/Makefile
+++ b/js/Makefile
@@ -17,7 +17,10 @@ all: npminstall
dist: npminstall
$(NPM) run gulp:dist
-clean: npminstall
+install:
+
+
+distclean clean: npminstall
$(NPM) run gulp:clean
lint: npminstall
diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js
index 76c2847da3b..0da65c3e282 100644
--- a/js/src/Ice/ConnectionI.js
+++ b/js/src/Ice/ConnectionI.js
@@ -1128,8 +1128,11 @@ var ConnectionI = Class({
throw this._exception;
}
var info = this._transceiver.getInfo();
- info.adapterName = this._adapter !== null ? this._adapter.getName() : "";
- info.incoming = this._incoming;
+ for(var p = info; p; p = p.underlying)
+ {
+ p.adapterName = this._adapter !== null ? this._adapter.getName() : "";
+ p.incoming = this._incoming;
+ }
return info;
},
setBufferSize: function(rcvSize, sndSize)
diff --git a/js/src/Ice/IncomingAsync.js b/js/src/Ice/IncomingAsync.js
index 1601419278c..a788fccd4f4 100644
--- a/js/src/Ice/IncomingAsync.js
+++ b/js/src/Ice/IncomingAsync.js
@@ -141,11 +141,12 @@ var IncomingAsync = Ice.Class({
s.push("\noperation: " + this._current.operation);
if(this._connection !== null)
{
- var connInfo = this._connection.getInfo();
- if(connInfo instanceof Ice.IPConnectionInfo)
+ for(var p = this._connection.getInfo(); p; p = p.underlying)
{
- var ipConnInfo = connInfo;
- s.push("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " + ipConnInfo.remotePort);
+ if(p instanceof Ice.IPConnectionInfo)
+ {
+ s.push("\nremote host: " + p.remoteAddress + " remote port: " + p.remotePort);
+ }
}
}
if(ex.stack)
diff --git a/js/src/Ice/Instance.js b/js/src/Ice/Instance.js
index d6a6d02822e..fa09b168058 100644
--- a/js/src/Ice/Instance.js
+++ b/js/src/Ice/Instance.js
@@ -362,7 +362,7 @@ var Instance = Ice.Class({
var wsEndpointFactory = new Ice.WSEndpointFactory(wsInstance, tcpEndpointFactory.clone(wsInstance));
this._endpointFactoryManager.add(wsEndpointFactory);
- var sslInstance = new Ice.ProtocolInstance(this, IceSSL.EndpointType, "ssl", true);
+ var sslInstance = new Ice.ProtocolInstance(this, Ice.SSLEndpointType, "ssl", true);
var sslEndpointFactory = new Ice.TcpEndpointFactory(sslInstance);
this._endpointFactoryManager.add(sslEndpointFactory);
diff --git a/js/src/Ice/OpaqueEndpointI.js b/js/src/Ice/OpaqueEndpointI.js
index a1d9e83d62c..a176adc1bff 100644
--- a/js/src/Ice/OpaqueEndpointI.js
+++ b/js/src/Ice/OpaqueEndpointI.js
@@ -51,7 +51,7 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
//
getInfo: function()
{
- return new OpaqueEndpointInfoI(-1, false, this._rawEncoding, this._rawBytes, this._type);
+ return new OpaqueEndpointInfoI(null, -1, false, this._rawEncoding, this._rawBytes, this._type);
},
//
// Return the endpoint type
diff --git a/js/src/Ice/TcpEndpointI.js b/js/src/Ice/TcpEndpointI.js
index ce14aa7d0d6..745ea52d10e 100644
--- a/js/src/Ice/TcpEndpointI.js
+++ b/js/src/Ice/TcpEndpointI.js
@@ -40,9 +40,9 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
//
getInfo: function()
{
- var info = this.secure() ? new IceSSL.EndpointInfo() : new Ice.TCPEndpointInfo();
+ var info = new Ice.TCPEndpointInfo();
this.fillEndpointInfo(info);
- return info;
+ return this.secure() ? new IceSSL.EndpointInfo(info, info.timeout, info.compress) : info;
},
//
// Return the timeout for the endpoint in milliseconds. 0 means
diff --git a/js/src/Ice/WSEndpoint.js b/js/src/Ice/WSEndpoint.js
index f466687f8d7..b36a2ca64b1 100644
--- a/js/src/Ice/WSEndpoint.js
+++ b/js/src/Ice/WSEndpoint.js
@@ -35,9 +35,11 @@ var WSEndpoint = Class(EndpointI, {
},
getInfo: function()
{
- var info = this._delegate.secure() ? new IceSSL.WSSEndpointInfo() : new Ice.WSEndpointInfo();
+ var info = new Ice.WSEndpointInfo();
info.resource = this._resource;
- this._delegate.fillEndpointInfo(info);
+ info.underlying = this._delegate.getInfo();
+ info.timeout = info.underlying.timeout;
+ info.compress = info.underlying.compress;
return info;
},
type: function()
diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js
index 32a3661ecf6..7ee934bb664 100644
--- a/js/src/Ice/browser/WSTransceiver.js
+++ b/js/src/Ice/browser/WSTransceiver.js
@@ -272,15 +272,13 @@ var WSTransceiver = Ice.Class({
getInfo: function()
{
Debug.assert(this._fd !== null);
- var info = this._secure ? new IceSSL.WSSConnectionInfo() : new Ice.WSConnectionInfo();
-
- //
- // The WebSocket API doens't provide this info
- //
- info.localAddress = "";
- info.localPort = -1;
- info.remoteAddress = this._addr.host;
- info.remotePort = this._addr.port;
+ var info = new Ice.WSConnectionInfo();
+ var tcpinfo = new Ice.TCPConnectionInfo();
+ tcpinfo.localAddress = "";
+ tcpinfo.localPort = -1;
+ tcpinfo.remoteAddress = this._addr.host;
+ tcpinfo.remotePort = this._addr.port;
+ info.underlying = this._secure ? new IceSSL.ConnectionInfo(tcpinfo, tcpinfo.timeout, tcpinfo.compress) : tcpinfo;
info.rcvSize = -1;
info.sndSize = this._maxSendPacketSize;
info.headers = {};
diff --git a/js/test/Ice/info/Client.js b/js/test/Ice/info/Client.js
index da20283d1b4..84ce30495f1 100644
--- a/js/test/Ice/info/Client.js
+++ b/js/test/Ice/info/Client.js
@@ -14,6 +14,30 @@
var Test = require("Test").Test;
var Promise = Ice.Promise;
+ function getTCPEndpointInfo(info)
+ {
+ for(var p = info; p; p = p.underlying)
+ {
+ if(p instanceof Ice.TCPEndpointInfo)
+ {
+ return p;
+ }
+ }
+ return null;
+ }
+
+ function getTCPConnectionInfo(info)
+ {
+ for(var p = info; p; p = p.underlying)
+ {
+ if(p instanceof Ice.TCPConnectionInfo)
+ {
+ return p;
+ }
+ }
+ return null;
+ }
+
function allTests(communicator, out)
{
var p = new Ice.Promise();
@@ -46,8 +70,8 @@
var p1 = communicator.stringToProxy(ref);
var endps = p1.ice_getEndpoints();
-
- var ipEndpoint = endps[0].getInfo();
+ var endpoint = endps[0].getInfo();
+ var ipEndpoint = getTCPEndpointInfo(endpoint);
test(ipEndpoint.host == "tcphost");
test(ipEndpoint.port == 10000);
test(ipEndpoint.timeout == 1200);
@@ -58,6 +82,10 @@
ipEndpoint.type() == Ice.WSEndpointType && !ipEndpoint.secure() ||
ipEndpoint.type() == Ice.WSSEndpointType && ipEndpoint.secure());
+ test(ipEndpoint.type() == Ice.TCPEndpointType && endpoint instanceof Ice.TCPEndpointInfo ||
+ ipEndpoint.type() == Ice.WSEndpointType && endpoint instanceof Ice.WSEndpointInfo ||
+ ipEndpoint.type() == Ice.WSSEndpointType && endpoint instanceof Ice.WSEndpointInfo);
+
var opaqueEndpoint = endps[1].getInfo();
test(opaqueEndpoint.rawEncoding.equals(new Ice.EncodingVersion(1, 8)));
}
@@ -74,7 +102,7 @@
return base.ice_getConnection().then(
function(conn)
{
- ipinfo = conn.getEndpoint().getInfo();
+ ipinfo = getTCPEndpointInfo(conn.getEndpoint().getInfo());
test(ipinfo.port == 12010);
test(!ipinfo.compress);
test(ipinfo.host == defaultHost);
@@ -106,19 +134,20 @@
connection.setBufferSize(1024, 2048);
info = connection.getInfo();
+ ipinfo = getTCPConnectionInfo(info);
test(!info.incoming);
test(info.adapterName.length === 0);
if(connection.type() != "ws" && connection.type() != "wss")
{
- test(info.localPort > 0);
+ test(ipinfo.localPort > 0);
}
- test(info.remotePort == 12010);
+ test(ipinfo.remotePort == 12010);
if(defaultHost == "127.0.0.1")
{
- test(info.remoteAddress == defaultHost);
+ test(ipinfo.remoteAddress == defaultHost);
if(connection.type() != "ws" && connection.type() != "wss")
{
- test(info.localAddress == defaultHost);
+ test(ipinfo.localAddress == defaultHost);
}
}
//test(info.rcvSize >= 1024);
diff --git a/js/test/Ice/optional/Client.js b/js/test/Ice/optional/Client.js
index 02cb3340d76..47b2093e02b 100644
--- a/js/test/Ice/optional/Client.js
+++ b/js/test/Ice/optional/Client.js
@@ -940,6 +940,7 @@
failCB,
function(ex)
{
+ console.log(ex);
test(ex instanceof Test.OptionalException);
test(ex.a === undefined);
test(ex.b === undefined);
diff --git a/objective-c/config/Make.rules b/objective-c/config/Make.rules
index 98e7a51fa8a..deb9b8972da 100644
--- a/objective-c/config/Make.rules
+++ b/objective-c/config/Make.rules
@@ -28,7 +28,7 @@ endif
#
# Build only few components with the static configuration (libraries)
#
-static_components = Ice IceObjC IceSSLObjC Glacier2ObjC IceStormObjC IceGridObjC
+static_components = Ice IceSSL IceObjC IceSSLObjC Glacier2ObjC IceStormObjC IceGridObjC
static_projects = test/%
static_ldflags += $(if $(filter program,$($1_target)),-ObjC)
@@ -100,5 +100,9 @@ define create-objc-test-project
$1_srcext := m
$1_dependencies := $$(or $$($1_dependencies),TestCommonObjC IceObjC)
$1_cppflags += -Itest/Ice
+
+# Also link with IceSSL when compiling the project with the static configuration
+$1[static]_dependencies := IceSSL
+
$(create-test-project)
endef
diff --git a/objective-c/include/objc/Ice/Initialize.h b/objective-c/include/objc/Ice/Initialize.h
index 7a32114d035..14603c81959 100644
--- a/objective-c/include/objc/Ice/Initialize.h
+++ b/objective-c/include/objc/Ice/Initialize.h
@@ -85,3 +85,10 @@ ICE_API @interface ICEUtil : NSObject
@interface ICEProtocolVersion(StringConv)
+(ICEProtocolVersion*) protocolVersionWithString:(NSString*)str;
@end
+
+extern void ICEregisterIceSSL(BOOL);
+extern void ICEregisterIceDiscovery(BOOL);
+extern void ICEregisterIceLocatorDiscovery(BOOL);
+#if defined(__APPLE__) && TARGET_OS_IPHONE > 0
+extern void ICEregisterIceIAP(BOOL);
+#endif
diff --git a/objective-c/src/Ice/ConnectionI.h b/objective-c/src/Ice/ConnectionI.h
index ec9bb84f68c..1ae96037183 100644
--- a/objective-c/src/Ice/ConnectionI.h
+++ b/objective-c/src/Ice/ConnectionI.h
@@ -8,11 +8,16 @@
// **********************************************************************
#import <objc/Ice/Connection.h>
-
#import <objc/Ice/LocalObject.h>
#include <Ice/Connection.h>
-//#include <IceSSL/ConnectionInfo.h>
+
+namespace IceObjC
+{
+
+ICE_API void registerConnectionInfoClass(Class cl);
+
+}
@interface ICEConnectionInfo (ICEInternal)
-(id) initWithConnectionInfo:(Ice::ConnectionInfo*)connectionInfo;
@@ -34,9 +39,5 @@
-(id) initWithWSConnectionInfo:(Ice::WSConnectionInfo*)wsConnectionInfo;
@end
-// @interface ICESSLConnectionInfo (ICEInternal)
-// -(id) initWithSSLConnectionInfo:(IceSSL::ConnectionInfo*)sslConnectionInfo;
-// @end
-
@interface ICEConnection : ICELocalObject<ICEConnection>
@end
diff --git a/objective-c/src/Ice/ConnectionI.mm b/objective-c/src/Ice/ConnectionI.mm
index 6e4e290b8b4..5dc6a0ff89b 100644
--- a/objective-c/src/Ice/ConnectionI.mm
+++ b/objective-c/src/Ice/ConnectionI.mm
@@ -2,7 +2,7 @@
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
-// This copy of Ice is licensed to you under the terms described in the
+// This copy of Ice is licensed to you the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
@@ -19,18 +19,92 @@
#import <objc/runtime.h>
+#define CONNECTION dynamic_cast<Ice::Connection*>(static_cast<IceUtil::Shared*>(cxxObject_))
+
+namespace
+{
+
+std::vector<Class>* connectionInfoClasses = 0;
+
+}
+
+namespace IceObjC
+{
+
+void
+registerConnectionInfoClass(Class cl)
+{
+ if(!connectionInfoClasses)
+ {
+ connectionInfoClasses = new std::vector<Class>();
+ }
+ connectionInfoClasses->push_back(cl);
+}
+
+}
+
@implementation ICEConnectionInfo (ICEInternal)
++(id) checkedConnectionInfoWithConnectionInfo:(Ice::ConnectionInfo*)connectionInfo
+{
+ assert(false);
+ return nil;
+}
+
++(id) connectionInfoWithConnectionInfo:(NSValue*)v
+{
+ Ice::ConnectionInfo* info = dynamic_cast<Ice::ConnectionInfo*>(reinterpret_cast<IceUtil::Shared*>(v.pointerValue));
+ if(!info)
+ {
+ return nil;
+ }
+
+ Ice::UDPConnectionInfoPtr udpInfo = Ice::UDPConnectionInfoPtr::dynamicCast(info);
+ if(udpInfo)
+ {
+ return [[ICEUDPConnectionInfo alloc] initWithUDPConnectionInfo:udpInfo.get()];
+ }
+
+ Ice::WSConnectionInfoPtr wsInfo = Ice::WSConnectionInfoPtr::dynamicCast(info);
+ if(wsInfo)
+ {
+ return [[ICEWSConnectionInfo alloc] initWithWSConnectionInfo:wsInfo.get()];
+ }
+
+ Ice::TCPConnectionInfoPtr tcpInfo = Ice::TCPConnectionInfoPtr::dynamicCast(info);
+ if(tcpInfo)
+ {
+ return [[ICETCPConnectionInfo alloc] initWithTCPConnectionInfo:tcpInfo.get()];
+ }
+
+ for(std::vector<Class>::const_iterator p = connectionInfoClasses->begin(); p != connectionInfoClasses->end(); ++p)
+ {
+ ICEConnectionInfo* r = [*p checkedConnectionInfoWithConnectionInfo:info];
+ if(r)
+ {
+ return r;
+ }
+ }
+
+ Ice::IPConnectionInfoPtr ipInfo = Ice::IPConnectionInfoPtr::dynamicCast(info);
+ if(ipInfo)
+ {
+ return [[ICEIPConnectionInfo alloc] initWithIPConnectionInfo:ipInfo.get()];
+ }
+
+ return [[ICEConnectionInfo alloc] initWithConnectionInfo:info];
+}
+
-(id) initWithConnectionInfo:(Ice::ConnectionInfo*)connectionInfo;
{
self = [super initWithCxxObject:connectionInfo];
if(self != nil)
{
+ self->underlying = [ICEConnectionInfo localObjectWithCxxObjectNoAutoRelease:connectionInfo->underlying.get()
+ allocator:@selector(connectionInfoWithConnectionInfo:)];
self->incoming = connectionInfo->incoming;
self->adapterName = [[NSString alloc] initWithUTF8String:connectionInfo->adapterName.c_str()];
self->connectionId = [[NSString alloc] initWithUTF8String:connectionInfo->connectionId.c_str()];
- self->rcvSize = connectionInfo->rcvSize;
- self->sndSize = connectionInfo->sndSize;
}
return self;
}
@@ -58,6 +132,11 @@
-(id) initWithTCPConnectionInfo:(Ice::TCPConnectionInfo*)tcpConnectionInfo
{
self = [super initWithIPConnectionInfo:tcpConnectionInfo];
+ if(self)
+ {
+ self->rcvSize = tcpConnectionInfo->rcvSize;
+ self->sndSize = tcpConnectionInfo->sndSize;
+ }
return self;
}
@end
@@ -71,6 +150,8 @@
{
self->mcastAddress = [[NSString alloc] initWithUTF8String:udpConnectionInfo->mcastAddress.c_str()];
self->mcastPort = udpConnectionInfo->mcastPort;
+ self->rcvSize = udpConnectionInfo->rcvSize;
+ self->sndSize = udpConnectionInfo->sndSize;
}
return self;
}
@@ -80,7 +161,7 @@
@implementation ICEWSConnectionInfo (ICEInternal)
-(id) initWithWSConnectionInfo:(Ice::WSConnectionInfo*)wsConnectionInfo
{
- self = [super initWithIPConnectionInfo:wsConnectionInfo];
+ self = [super initWithConnectionInfo:wsConnectionInfo];
if(self)
{
self->headers = toNSDictionary(wsConnectionInfo->headers);
@@ -180,8 +261,6 @@ private:
}
-#define CONNECTION dynamic_cast<Ice::Connection*>(static_cast<IceUtil::Shared*>(cxxObject_))
-
@implementation ICEConnection
-(void) close:(BOOL)force
{
@@ -344,46 +423,8 @@ private:
NSException* nsex = nil;
try
{
- Ice::ConnectionInfoPtr info = CONNECTION->getInfo();
- if(!info)
- {
- return nil;
- }
-
- Ice::UDPConnectionInfoPtr udpInfo = Ice::UDPConnectionInfoPtr::dynamicCast(info);
- if(udpInfo)
- {
- return [[[ICEUDPConnectionInfo alloc] initWithUDPConnectionInfo:udpInfo.get()] autorelease];
- }
-
- Ice::WSConnectionInfoPtr wsInfo = Ice::WSConnectionInfoPtr::dynamicCast(info);
- if(wsInfo)
- {
- return [[[ICEWSConnectionInfo alloc] initWithWSConnectionInfo:wsInfo.get()] autorelease];
- }
-
- Ice::TCPConnectionInfoPtr tcpInfo = Ice::TCPConnectionInfoPtr::dynamicCast(info);
- if(tcpInfo)
- {
- return [[[ICETCPConnectionInfo alloc] initWithTCPConnectionInfo:tcpInfo.get()] autorelease];
- }
-
- std::ostringstream os;
- os << "connectionInfoWithType_" << CONNECTION->type() << ":";
- SEL selector = sel_registerName(os.str().c_str());
- if([ICEConnectionInfo respondsToSelector:selector])
- {
- IceUtil::Shared* shared = info.get();
- return [ICEConnectionInfo performSelector:selector withObject:[NSValue valueWithPointer:shared]];
- }
-
- Ice::IPConnectionInfoPtr ipInfo = Ice::IPConnectionInfoPtr::dynamicCast(info);
- if(ipInfo)
- {
- return [[[ICEIPConnectionInfo alloc] initWithIPConnectionInfo:ipInfo.get()] autorelease];
- }
-
- return [[[ICEConnectionInfo alloc] initWithConnectionInfo:info.get()] autorelease];
+ return [ICEConnectionInfo localObjectWithCxxObject:CONNECTION->getInfo().get()
+ allocator:@selector(connectionInfoWithConnectionInfo:)];
}
catch(const std::exception& ex)
{
diff --git a/objective-c/src/Ice/EndpointI.h b/objective-c/src/Ice/EndpointI.h
index 60db2cb2cca..360b8ffda23 100644
--- a/objective-c/src/Ice/EndpointI.h
+++ b/objective-c/src/Ice/EndpointI.h
@@ -8,11 +8,17 @@
// **********************************************************************
#import <objc/Ice/Endpoint.h>
-
#import <objc/Ice/LocalObject.h>
#include <Ice/Endpoint.h>
+namespace IceObjC
+{
+
+ICE_API void registerEndpointInfoClass(Class cl);
+
+}
+
@interface ICEEndpoint : ICELocalObject<ICEEndpoint>
-(Ice::Endpoint*) endpoint;
@end
diff --git a/objective-c/src/Ice/EndpointI.mm b/objective-c/src/Ice/EndpointI.mm
index d8e52ded896..757a19a266c 100644
--- a/objective-c/src/Ice/EndpointI.mm
+++ b/objective-c/src/Ice/EndpointI.mm
@@ -21,90 +21,93 @@
#define ENDPOINT dynamic_cast<Ice::Endpoint*>(static_cast<IceUtil::Shared*>(cxxObject_))
#define ENDPOINTINFO dynamic_cast<Ice::EndpointInfo*>(static_cast<IceUtil::Shared*>(cxxObject_))
-@implementation ICEEndpoint
-
--(Ice::Endpoint*) endpoint
+namespace
{
- return ENDPOINT;
+
+std::vector<Class>* endpointInfoClasses = 0;
+
}
--(ICEEndpointInfo*) getInfo
+namespace IceObjC
{
- NSException* nsex = nil;
- try
+
+void
+registerEndpointInfoClass(Class cl)
+{
+ if(!endpointInfoClasses)
{
- Ice::EndpointInfoPtr info = ENDPOINT->getInfo();
- if(!info)
- {
- return nil;
- }
-
- Ice::UDPEndpointInfoPtr udpInfo = Ice::UDPEndpointInfoPtr::dynamicCast(info);
- if(udpInfo)
- {
- return [[[ICEUDPEndpointInfo alloc] initWithUDPEndpointInfo:udpInfo.get()] autorelease];
- }
+ endpointInfoClasses = new std::vector<Class>();
+ }
+ endpointInfoClasses->push_back(cl);
+}
- Ice::WSEndpointInfoPtr wsInfo = Ice::WSEndpointInfoPtr::dynamicCast(info);
- if(wsInfo)
- {
- return [[[ICEWSEndpointInfo alloc] initWithWSEndpointInfo:wsInfo.get()] autorelease];
- }
+}
- Ice::TCPEndpointInfoPtr tcpInfo = Ice::TCPEndpointInfoPtr::dynamicCast(info);
- if(tcpInfo)
- {
- return [[[ICETCPEndpointInfo alloc] initWithTCPEndpointInfo:tcpInfo.get()] autorelease];
- }
+@implementation ICEEndpointInfo(ICEInternal)
- Ice::OpaqueEndpointInfoPtr opaqueInfo = Ice::OpaqueEndpointInfoPtr::dynamicCast(info);
- if(opaqueInfo)
- {
- return [[[ICEOpaqueEndpointInfo alloc] initWithOpaqueEndpointInfo:opaqueInfo.get()] autorelease];
- }
-
- std::ostringstream os;
- os << "endpointInfoWithType_" << info->type() << ":";
- SEL selector = sel_registerName(os.str().c_str());
- if([ICEEndpointInfo respondsToSelector:selector])
- {
- IceUtil::Shared* shared = info.get();
- return [ICEEndpointInfo performSelector:selector withObject:[NSValue valueWithPointer:shared]];
- }
++(id) checkedEndpointInfoWithEndpointInfo:(Ice::EndpointInfo*)endpointInfo
+{
+ assert(false);
+ return nil;
+}
- Ice::IPEndpointInfoPtr ipInfo = Ice::IPEndpointInfoPtr::dynamicCast(info);
- if(ipInfo)
- {
- return [[[ICEIPEndpointInfo alloc] initWithIPEndpointInfo:ipInfo.get()] autorelease];
- }
++(id) endpointInfoWithEndpointInfo:(NSValue*)v
+{
+ Ice::EndpointInfo* info = dynamic_cast<Ice::EndpointInfo*>(reinterpret_cast<IceUtil::Shared*>([v pointerValue]));
+ if(!info)
+ {
+ return nil;
+ }
- return [[[ICEEndpointInfo alloc] initWithEndpointInfo:info.get()] autorelease];
+ Ice::UDPEndpointInfoPtr udpInfo = Ice::UDPEndpointInfoPtr::dynamicCast(info);
+ if(udpInfo)
+ {
+ return [[ICEUDPEndpointInfo alloc] initWithUDPEndpointInfo:udpInfo.get()];
}
- catch(const std::exception& ex)
+
+ Ice::WSEndpointInfoPtr wsInfo = Ice::WSEndpointInfoPtr::dynamicCast(info);
+ if(wsInfo)
{
- nsex = toObjCException(ex);
+ return [[ICEWSEndpointInfo alloc] initWithWSEndpointInfo:wsInfo.get()];
}
- if(nsex != nil)
+
+ Ice::TCPEndpointInfoPtr tcpInfo = Ice::TCPEndpointInfoPtr::dynamicCast(info);
+ if(tcpInfo)
{
- @throw nsex;
+ return [[ICETCPEndpointInfo alloc] initWithTCPEndpointInfo:tcpInfo.get()];
}
- return nil;
-}
--(NSMutableString*) toString
-{
- return [toNSMutableString(ENDPOINT->toString()) autorelease];
-}
+ Ice::OpaqueEndpointInfoPtr opaqueInfo = Ice::OpaqueEndpointInfoPtr::dynamicCast(info);
+ if(opaqueInfo)
+ {
+ return [[ICEOpaqueEndpointInfo alloc] initWithOpaqueEndpointInfo:opaqueInfo.get()];
+ }
-@end
+ for(std::vector<Class>::const_iterator p = endpointInfoClasses->begin(); p != endpointInfoClasses->end(); ++p)
+ {
+ ICEEndpointInfo* r = [*p checkedEndpointInfoWithEndpointInfo:info];
+ if(r)
+ {
+ return r;
+ }
+ }
-@implementation ICEEndpointInfo(ICEInternal)
+ Ice::IPEndpointInfoPtr ipInfo = Ice::IPEndpointInfoPtr::dynamicCast(info);
+ if(ipInfo)
+ {
+ return [[ICEIPEndpointInfo alloc] initWithIPEndpointInfo:ipInfo.get()];
+ }
+
+ return [[ICEEndpointInfo alloc] initWithEndpointInfo:info];
+}
-(id) initWithEndpointInfo:(Ice::EndpointInfo*)endpointInfo;
{
self = [super initWithCxxObject:endpointInfo];
if(self)
{
+ self->underlying = [ICEEndpointInfo localObjectWithCxxObjectNoAutoRelease:endpointInfo->underlying.get()
+ allocator:@selector(endpointInfoWithEndpointInfo:)];
self->timeout = endpointInfo->timeout;
self->compress = endpointInfo->compress;
}
@@ -170,7 +173,7 @@
-(id) initWithWSEndpointInfo:(Ice::WSEndpointInfo*)wsEndpointInfo
{
- self = [super initWithIPEndpointInfo:wsEndpointInfo];
+ self = [super initWithEndpointInfo:wsEndpointInfo];
if(self)
{
self->resource = [[NSString alloc] initWithUTF8String:wsEndpointInfo->resource.c_str()];
@@ -194,3 +197,37 @@
}
@end
+
+@implementation ICEEndpoint
+
+-(Ice::Endpoint*) endpoint
+{
+ return ENDPOINT;
+}
+
+-(ICEEndpointInfo*) getInfo
+{
+ NSException* nsex = nil;
+ try
+ {
+ return [ICEEndpointInfo localObjectWithCxxObject:ENDPOINT->getInfo().get()
+ allocator:@selector(endpointInfoWithEndpointInfo:)];
+ }
+ catch(const std::exception& ex)
+ {
+ nsex = toObjCException(ex);
+ }
+ if(nsex != nil)
+ {
+ @throw nsex;
+ }
+ return nil;
+}
+
+-(NSMutableString*) toString
+{
+ return [toNSMutableString(ENDPOINT->toString()) autorelease];
+}
+
+@end
+
diff --git a/objective-c/src/Ice/Initialize.mm b/objective-c/src/Ice/Initialize.mm
index b40c0672f1d..b1ea0d6dd38 100644
--- a/objective-c/src/Ice/Initialize.mm
+++ b/objective-c/src/Ice/Initialize.mm
@@ -21,6 +21,7 @@
#import <objc/Ice/LocalException.h>
#include <Ice/Initialize.h>
+#include <Ice/RegisterPlugins.h>
#include <IceUtil/UUID.h>
#include <IceUtil/MutexPtrLock.h>
@@ -33,6 +34,21 @@
# define ICE_USE_CFSTREAM 1
#endif
+extern "C"
+{
+
+Ice::Plugin*
+createIceSSL(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
+Ice::Plugin*
+createIceDiscovery(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
+Ice::Plugin*
+createIceLocatorDiscovery(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
+#if defined(__APPLE__) && TARGET_OS_IPHONE > 0
+Ice::Plugin*
+createIceIAP(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&);
+#endif
+}
+
namespace
{
typedef std::map<int, std::string> CompactIdMap;
diff --git a/objective-c/src/Ice/LocalObject.mm b/objective-c/src/Ice/LocalObject.mm
index 7c80effca05..70b7dc692fa 100644
--- a/objective-c/src/Ice/LocalObject.mm
+++ b/objective-c/src/Ice/LocalObject.mm
@@ -16,7 +16,7 @@
#define CXXOBJECT ((IceUtil::Shared*)cxxObject_)
-namespace
+namespace
{
std::map<IceUtil::Shared*, ICELocalObject*> cachedObjects;
@@ -59,7 +59,7 @@ std::map<IceUtil::Shared*, ICELocalObject*> cachedObjects;
}
-(void) dealloc
-{
+{
if(cxxObject_)
{
//
@@ -84,7 +84,7 @@ std::map<IceUtil::Shared*, ICELocalObject*> cachedObjects;
{
return nil;
}
-
+
@synchronized([ICELocalObject class])
{
std::map<IceUtil::Shared*, ICELocalObject*>::const_iterator p = cachedObjects.find(arg);
@@ -102,7 +102,7 @@ std::map<IceUtil::Shared*, ICELocalObject*> cachedObjects;
{
return nil;
}
-
+
@synchronized([ICELocalObject class])
{
std::map<IceUtil::Shared*, ICELocalObject*>::const_iterator p = cachedObjects.find(arg);
@@ -118,11 +118,37 @@ std::map<IceUtil::Shared*, ICELocalObject*> cachedObjects;
return nil; // Keep the compiler happy.
}
++(id) localObjectWithCxxObjectNoAutoRelease:(IceUtil::Shared*)arg allocator:(SEL)alloc
+{
+ if(arg == 0)
+ {
+ return nil;
+ }
+
+ @synchronized([ICELocalObject class])
+ {
+ std::map<IceUtil::Shared*, ICELocalObject*>::const_iterator p = cachedObjects.find(arg);
+ if(p != cachedObjects.end())
+ {
+ return [p->second retain];
+ }
+ else
+ {
+ return [self performSelector:alloc withObject:[NSValue valueWithPointer:arg]];
+ }
+ }
+ return nil; // Keep the compiler happy.
+}
+
+(id) localObjectWithCxxObject:(IceUtil::Shared*)arg
{
return [[self localObjectWithCxxObjectNoAutoRelease:arg] autorelease];
}
++(id) localObjectWithCxxObject:(IceUtil::Shared*)arg allocator:(SEL)alloc
+{
+ return [[self localObjectWithCxxObjectNoAutoRelease:arg allocator:alloc] autorelease];
+}
-(id) retain
{
@@ -132,7 +158,7 @@ std::map<IceUtil::Shared*, ICELocalObject*> cachedObjects;
-(oneway void) release
{
- @synchronized([ICELocalObject class])
+ @synchronized([ICELocalObject class])
{
if(NSDecrementExtraRefCountWasZero(self))
{
diff --git a/objective-c/src/Ice/LocalObjectI.h b/objective-c/src/Ice/LocalObjectI.h
index 35790a2dcac..bb8eec04ed1 100644
--- a/objective-c/src/Ice/LocalObjectI.h
+++ b/objective-c/src/Ice/LocalObjectI.h
@@ -24,7 +24,9 @@ class Shared;
+(id) getLocalObjectWithCxxObjectNoAutoRelease:(IceUtil::Shared*)arg;
+(id) localObjectWithCxxObjectNoAutoRelease:(IceUtil::Shared*)arg;
++(id) localObjectWithCxxObjectNoAutoRelease:(IceUtil::Shared*)arg allocator:(SEL)alloc;
+(id) localObjectWithCxxObject:(IceUtil::Shared*)arg;
++(id) localObjectWithCxxObject:(IceUtil::Shared*)arg allocator:(SEL)alloc;
-(IceUtil::Shared*) cxxObject;
@end
diff --git a/objective-c/src/IceSSL/ConnectionInfoI.mm b/objective-c/src/IceSSL/ConnectionInfoI.mm
index 337d4d46955..53357fd3de5 100644
--- a/objective-c/src/IceSSL/ConnectionInfoI.mm
+++ b/objective-c/src/IceSSL/ConnectionInfoI.mm
@@ -16,9 +16,14 @@
@implementation ICESSLConnectionInfo (IceSSL)
++(void) load
+{
+ IceObjC::registerConnectionInfoClass([ICESSLConnectionInfo class]);
+}
+
-(id) initWithSSLConnectionInfo:(IceSSL::ConnectionInfo*)sslConnectionInfo
{
- self = [super initWithIPConnectionInfo:sslConnectionInfo];
+ self = [super initWithConnectionInfo:sslConnectionInfo];
if(self)
{
self->cipher = [[NSString alloc] initWithUTF8String:sslConnectionInfo->cipher.c_str()];
@@ -28,56 +33,12 @@
return self;
}
-@end
-
-@implementation ICEConnectionInfo (IceSSL)
-
-+(id) connectionInfoWithType_ssl:(NSValue*)connectionInfo
++(id) checkedConnectionInfoWithConnectionInfo:(Ice::ConnectionInfo*)connectionInfo
{
- if(!connectionInfo)
- {
- return nil;
- }
-
- IceUtil::Shared* shared = reinterpret_cast<IceUtil::Shared*>([connectionInfo pointerValue]);
- IceSSL::ConnectionInfo* obj = dynamic_cast<IceSSL::ConnectionInfo*>(shared);
- if(obj)
- {
- return [[[ICESSLConnectionInfo alloc] initWithSSLConnectionInfo:obj] autorelease];
- }
- return nil;
-}
-
-@end
-
-@implementation ICESSLWSSConnectionInfo (IceSSL)
-
--(id) initWithWSSConnectionInfo:(IceSSL::WSSConnectionInfo*)wssConnectionInfo
-{
- self = [super initWithSSLConnectionInfo:wssConnectionInfo];
- if(self)
- {
- self->headers = toNSDictionary(wssConnectionInfo->headers);
- }
- return self;
-}
-
-@end
-
-@implementation ICEConnectionInfo (IceSSLWSS)
-
-+(id) connectionInfoWithType_wss:(NSValue*)connectionInfo
-{
- if(!connectionInfo)
- {
- return nil;
- }
-
- IceUtil::Shared* shared = reinterpret_cast<IceUtil::Shared*>([connectionInfo pointerValue]);
- IceSSL::WSSConnectionInfo* obj = dynamic_cast<IceSSL::WSSConnectionInfo*>(shared);
- if(obj)
+ IceSSL::ConnectionInfo* sslConnectionInfo = dynamic_cast<IceSSL::ConnectionInfo*>(connectionInfo);
+ if(sslConnectionInfo)
{
- return [[[ICESSLWSSConnectionInfo alloc] initWithWSSConnectionInfo:obj] autorelease];
+ return [[ICESSLConnectionInfo alloc] initWithSSLConnectionInfo:sslConnectionInfo];
}
return nil;
}
diff --git a/objective-c/src/IceSSL/EndpointInfoI.mm b/objective-c/src/IceSSL/EndpointInfoI.mm
index e149256f315..ce6cd7ee401 100644
--- a/objective-c/src/IceSSL/EndpointInfoI.mm
+++ b/objective-c/src/IceSSL/EndpointInfoI.mm
@@ -8,73 +8,25 @@
// **********************************************************************
#import <objc/IceSSL/EndpointInfo.h>
-#import <ConnectionI.h>
+#import <EndpointI.h>
#import <LocalObjectI.h>
#import <Util.h>
#include <IceSSL/EndpointInfo.h>
@implementation ICESSLEndpointInfo (IceSSL)
-
--(id) initWithSSLEndpointInfo:(IceSSL::EndpointInfo*)sslEndpointInfo
++(void) load
{
- self = [super initWithIPEndpointInfo:sslEndpointInfo];
- return self;
+ IceObjC::registerEndpointInfoClass([ICESSLEndpointInfo class]);
}
-@end
-
-@implementation ICEEndpointInfo (IceSSL)
-
-+(id) endpointInfoWithType_2:(NSValue*)endpointInfo
++(id) checkedEndpointInfoWithEndpointInfo:(Ice::EndpointInfo*)endpointInfo
{
- if(!endpointInfo)
+ IceSSL::EndpointInfo* sslEndpointInfo = dynamic_cast<IceSSL::EndpointInfo*>(endpointInfo);
+ if(sslEndpointInfo)
{
- return nil;
- }
-
- IceUtil::Shared* shared = reinterpret_cast<IceUtil::Shared*>([endpointInfo pointerValue]);
- IceSSL::EndpointInfo* obj = dynamic_cast<IceSSL::EndpointInfo*>(shared);
- if(obj)
- {
- return [[[ICESSLEndpointInfo alloc] initWithSSLEndpointInfo:obj] autorelease];
+ return [[ICESSLEndpointInfo alloc] initWithEndpointInfo:sslEndpointInfo];
}
return nil;
}
-
@end
-
-@implementation ICESSLWSSEndpointInfo (IceSSL)
-
--(id) initWithWSSEndpointInfo:(IceSSL::WSSEndpointInfo*)wssEndpointInfo
-{
- self = [super initWithSSLEndpointInfo:wssEndpointInfo];
- if(self)
- {
- self->resource = [[NSString alloc] initWithUTF8String:wssEndpointInfo->resource.c_str()];
- }
- return self;
-}
-
-@end
-
-@implementation ICEEndpointInfo (IceSSLWSS)
-
-+(id) endpointInfoWithType_5:(NSValue*)endpointInfo
-{
- if(!endpointInfo)
- {
- return nil;
- }
-
- IceUtil::Shared* shared = reinterpret_cast<IceUtil::Shared*>([endpointInfo pointerValue]);
- IceSSL::WSSEndpointInfo* obj = dynamic_cast<IceSSL::WSSEndpointInfo*>(shared);
- if(obj)
- {
- return [[[ICESSLWSSEndpointInfo alloc] initWithWSSEndpointInfo:obj] autorelease];
- }
- return nil;
-}
-
-@end
-
diff --git a/objective-c/test/Ice/acm/Client.m b/objective-c/test/Ice/acm/Client.m
index 09a22c9a0d1..ff8b618aa96 100644
--- a/objective-c/test/Ice/acm/Client.m
+++ b/objective-c/test/Ice/acm/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/acm/Server.m b/objective-c/test/Ice/acm/Server.m
index 158a3eea5ae..f955a673b06 100644
--- a/objective-c/test/Ice/acm/Server.m
+++ b/objective-c/test/Ice/acm/Server.m
@@ -37,6 +37,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
@autoreleasepool
{
int status;
diff --git a/objective-c/test/Ice/adapterDeactivation/Client.m b/objective-c/test/Ice/adapterDeactivation/Client.m
index 45fd859e636..5b14e7fafd6 100644
--- a/objective-c/test/Ice/adapterDeactivation/Client.m
+++ b/objective-c/test/Ice/adapterDeactivation/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -37,7 +44,7 @@ main(int argc, char* argv[])
initData.properties = defaultClientProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestAdapterDeactivation", @"::Test",
+ @"TestAdapterDeactivation", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/adapterDeactivation/Collocated.m b/objective-c/test/Ice/adapterDeactivation/Collocated.m
index 7bc691a652d..159430fc682 100644
--- a/objective-c/test/Ice/adapterDeactivation/Collocated.m
+++ b/objective-c/test/Ice/adapterDeactivation/Collocated.m
@@ -32,6 +32,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/adapterDeactivation/Server.m b/objective-c/test/Ice/adapterDeactivation/Server.m
index 0f6c42bffec..bc55c8015c1 100644
--- a/objective-c/test/Ice/adapterDeactivation/Server.m
+++ b/objective-c/test/Ice/adapterDeactivation/Server.m
@@ -32,6 +32,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -43,7 +50,7 @@ main(int argc, char* argv[])
initData.properties = defaultServerProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestAdapterDeactivation", @"::Test",
+ @"TestAdapterDeactivation", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/admin/Client.m b/objective-c/test/Ice/admin/Client.m
index b508dd907e3..5bd9aa6251a 100644
--- a/objective-c/test/Ice/admin/Client.m
+++ b/objective-c/test/Ice/admin/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -36,7 +43,7 @@ main(int argc, char* argv[])
initData.properties = defaultClientProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestAdmin", @"::Test",
+ @"TestAdmin", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/admin/Server.m b/objective-c/test/Ice/admin/Server.m
index 8a0d5a444c5..feb14756b80 100644
--- a/objective-c/test/Ice/admin/Server.m
+++ b/objective-c/test/Ice/admin/Server.m
@@ -36,6 +36,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
@autoreleasepool
{
int status;
@@ -47,7 +54,7 @@ main(int argc, char* argv[])
initData.properties = defaultServerProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestAdmin", @"::Test",
+ @"TestAdmin", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/ami/Client.m b/objective-c/test/Ice/ami/Client.m
index bd19d723a37..debfec0d3de 100644
--- a/objective-c/test/Ice/ami/Client.m
+++ b/objective-c/test/Ice/ami/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/ami/Collocated.m b/objective-c/test/Ice/ami/Collocated.m
index c98da80dcd5..a950e3d6074 100644
--- a/objective-c/test/Ice/ami/Collocated.m
+++ b/objective-c/test/Ice/ami/Collocated.m
@@ -43,6 +43,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/ami/Server.m b/objective-c/test/Ice/ami/Server.m
index 8fa235a3cd6..2a0d28c4eb5 100644
--- a/objective-c/test/Ice/ami/Server.m
+++ b/objective-c/test/Ice/ami/Server.m
@@ -10,7 +10,7 @@
#import <objc/Ice.h>
#import <ami/TestI.h>
#import <TestCommon.h>
-
+
static int
run(id<ICECommunicator> communicator)
{
@@ -21,7 +21,7 @@ run(id<ICECommunicator> communicator)
id<ICEObjectAdapter> adapter = [communicator createObjectAdapter:@"TestAMIAdapter"];
id<ICEObjectAdapter> adapter2 = [communicator createObjectAdapter:@"ControllerAdapter"];
- TestAMITestIntfControllerI* testController
+ TestAMITestIntfControllerI* testController
= ICE_AUTORELEASE([[TestAMITestIntfControllerI alloc] initWithAdapter:adapter]);
[adapter add:[TestAMITestIntfI testIntf] identity:[communicator stringToIdentity:@"test"]];
@@ -43,6 +43,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -61,7 +68,7 @@ main(int argc, char* argv[])
[initData.properties setProperty:@"Ice.Warn.Dispatch" value:@"0"];
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestAMI", @"::Test",
+ @"TestAMI", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/binding/Client.m b/objective-c/test/Ice/binding/Client.m
index da9753450bc..22ded401d3b 100644
--- a/objective-c/test/Ice/binding/Client.m
+++ b/objective-c/test/Ice/binding/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -36,7 +43,7 @@ main(int argc, char* argv[])
initData.properties = defaultClientProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestBinding", @"::Test",
+ @"TestBinding", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/binding/Server.m b/objective-c/test/Ice/binding/Server.m
index 1072e2562a0..268196f5b6b 100644
--- a/objective-c/test/Ice/binding/Server.m
+++ b/objective-c/test/Ice/binding/Server.m
@@ -35,6 +35,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
@autoreleasepool
{
int status;
@@ -46,7 +53,7 @@ main(int argc, char* argv[])
initData.properties = defaultServerProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestBinding", @"::Test",
+ @"TestBinding", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/defaultServant/Client.m b/objective-c/test/Ice/defaultServant/Client.m
index 4e0eceec1fa..0c79bc1d348 100644
--- a/objective-c/test/Ice/defaultServant/Client.m
+++ b/objective-c/test/Ice/defaultServant/Client.m
@@ -152,6 +152,13 @@ defaultServantServer(int argc, char* argv[])
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/defaultValue/Client.m b/objective-c/test/Ice/defaultValue/Client.m
index 7a57ab2ae20..6bfd3d42c05 100644
--- a/objective-c/test/Ice/defaultValue/Client.m
+++ b/objective-c/test/Ice/defaultValue/Client.m
@@ -26,6 +26,13 @@ run()
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
@autoreleasepool
{
int status;
diff --git a/objective-c/test/Ice/dispatcher/Client.m b/objective-c/test/Ice/dispatcher/Client.m
index 1ce8fb7c3f7..cd7722e3f93 100644
--- a/objective-c/test/Ice/dispatcher/Client.m
+++ b/objective-c/test/Ice/dispatcher/Client.m
@@ -28,6 +28,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -43,7 +50,7 @@ main(int argc, char* argv[])
};
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestDispatcher", @"::Test",
+ @"TestDispatcher", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/dispatcher/Collocated.m b/objective-c/test/Ice/dispatcher/Collocated.m
index 0d5c99bd92e..94d547bfa4b 100644
--- a/objective-c/test/Ice/dispatcher/Collocated.m
+++ b/objective-c/test/Ice/dispatcher/Collocated.m
@@ -46,6 +46,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/dispatcher/Server.m b/objective-c/test/Ice/dispatcher/Server.m
index 0933fbb62fe..0513b436a7f 100644
--- a/objective-c/test/Ice/dispatcher/Server.m
+++ b/objective-c/test/Ice/dispatcher/Server.m
@@ -46,6 +46,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/enums/Client.m b/objective-c/test/Ice/enums/Client.m
index 4da698b7e10..e0232a0302b 100644
--- a/objective-c/test/Ice/enums/Client.m
+++ b/objective-c/test/Ice/enums/Client.m
@@ -29,6 +29,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/enums/Server.m b/objective-c/test/Ice/enums/Server.m
index 3f2bb79af7b..b3489bb3c21 100644
--- a/objective-c/test/Ice/enums/Server.m
+++ b/objective-c/test/Ice/enums/Server.m
@@ -32,6 +32,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/exceptions/Client.m b/objective-c/test/Ice/exceptions/Client.m
index 40de1bd0eb3..7fbc7f6bac7 100644
--- a/objective-c/test/Ice/exceptions/Client.m
+++ b/objective-c/test/Ice/exceptions/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/exceptions/Collocated.m b/objective-c/test/Ice/exceptions/Collocated.m
index 5cf6f91d1b6..c86e8085226 100644
--- a/objective-c/test/Ice/exceptions/Collocated.m
+++ b/objective-c/test/Ice/exceptions/Collocated.m
@@ -32,6 +32,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/exceptions/Server.m b/objective-c/test/Ice/exceptions/Server.m
index fe02f3f2915..259d547a884 100644
--- a/objective-c/test/Ice/exceptions/Server.m
+++ b/objective-c/test/Ice/exceptions/Server.m
@@ -44,6 +44,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/facets/Client.m b/objective-c/test/Ice/facets/Client.m
index 40c70370bc5..650f5c914b6 100644
--- a/objective-c/test/Ice/facets/Client.m
+++ b/objective-c/test/Ice/facets/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/facets/Collocated.m b/objective-c/test/Ice/facets/Collocated.m
index 6c1b20c5d8a..b2810cd1cab 100644
--- a/objective-c/test/Ice/facets/Collocated.m
+++ b/objective-c/test/Ice/facets/Collocated.m
@@ -37,6 +37,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/facets/Server.m b/objective-c/test/Ice/facets/Server.m
index 46e473ceb55..1f0d4cde3bd 100644
--- a/objective-c/test/Ice/facets/Server.m
+++ b/objective-c/test/Ice/facets/Server.m
@@ -40,6 +40,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/faultTolerance/Client.m b/objective-c/test/Ice/faultTolerance/Client.m
index 69d0ba79ac9..b5738ecdfe7 100644
--- a/objective-c/test/Ice/faultTolerance/Client.m
+++ b/objective-c/test/Ice/faultTolerance/Client.m
@@ -59,6 +59,13 @@ run(int argc, char* argv[], id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/faultTolerance/Server.m b/objective-c/test/Ice/faultTolerance/Server.m
index ee8cb8f1cba..fdba3426941 100644
--- a/objective-c/test/Ice/faultTolerance/Server.m
+++ b/objective-c/test/Ice/faultTolerance/Server.m
@@ -63,6 +63,13 @@ run(int argc, char** argv, id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/hash/Client.m b/objective-c/test/Ice/hash/Client.m
index 6dc214a9b4e..2b33ad90d58 100644
--- a/objective-c/test/Ice/hash/Client.m
+++ b/objective-c/test/Ice/hash/Client.m
@@ -26,6 +26,13 @@ run()
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/hold/Client.m b/objective-c/test/Ice/hold/Client.m
index e0321813874..ef4f2d23932 100644
--- a/objective-c/test/Ice/hold/Client.m
+++ b/objective-c/test/Ice/hold/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -37,7 +44,7 @@ main(int argc, char* argv[])
initData.properties = defaultClientProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestHold", @"::Test",
+ @"TestHold", @"::Test",
nil];
#endif
communicator = [ICEUtil createCommunicator:&argc argv:argv initData:initData];
diff --git a/objective-c/test/Ice/hold/Server.m b/objective-c/test/Ice/hold/Server.m
index 1337a12e108..6db8bd58c5f 100644
--- a/objective-c/test/Ice/hold/Server.m
+++ b/objective-c/test/Ice/hold/Server.m
@@ -15,20 +15,20 @@ static int
run(id<ICECommunicator> communicator)
{
[[communicator getProperties] setProperty:@"TestAdapter1.Endpoints" value:@"default -p 12010 -t 10000:udp"];
- [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.Size" value:@"5"];
- [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.SizeMax" value:@"5"];
- [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.SizeWarn" value:@"0"];
+ [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.Size" value:@"5"];
+ [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.SizeMax" value:@"5"];
+ [[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.SizeWarn" value:@"0"];
[[communicator getProperties] setProperty:@"TestAdapter1.ThreadPool.Serialize" value:@"0"];
id<ICEObjectAdapter> adapter1 = [communicator createObjectAdapter:@"TestAdapter1"];
[[communicator getProperties] setProperty:@"TestAdapter2.Endpoints" value:@"default -p 12011 -t 10000:udp"];
- [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.Size" value:@"5"];
- [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.SizeMax" value:@"5"];
- [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.SizeWarn" value:@"0"];
+ [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.Size" value:@"5"];
+ [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.SizeMax" value:@"5"];
+ [[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.SizeWarn" value:@"0"];
[[communicator getProperties] setProperty:@"TestAdapter2.ThreadPool.Serialize" value:@"1"];
id<ICEObjectAdapter> adapter2 = [communicator createObjectAdapter:@"TestAdapter2"];
-
+
[adapter1 add:[HoldI hold] identity:[communicator stringToIdentity:@"hold"]];
[adapter2 add:[HoldI hold] identity:[communicator stringToIdentity:@"hold"]];
@@ -49,6 +49,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
@autoreleasepool
{
int status;
@@ -60,7 +67,7 @@ main(int argc, char* argv[])
initData.properties = defaultServerProperties(&argc, argv);
#if TARGET_OS_IPHONE
initData.prefixTable__ = [NSDictionary dictionaryWithObjectsAndKeys:
- @"TestHold", @"::Test",
+ @"TestHold", @"::Test",
nil];
#endif
diff --git a/objective-c/test/Ice/info/AllTests.m b/objective-c/test/Ice/info/AllTests.m
index 1fcb0fc9325..413855c279e 100644
--- a/objective-c/test/Ice/info/AllTests.m
+++ b/objective-c/test/Ice/info/AllTests.m
@@ -12,6 +12,31 @@
#import <TestCommon.h>
#import <InfoTest.h>
+static ICETCPEndpointInfo<ICEEndpointInfo>*
+getTCPEndpointInfo(ICEEndpointInfo<ICEEndpointInfo>* info)
+{
+ for(; info; info = info.underlying)
+ {
+ if([info isKindOfClass:[ICETCPEndpointInfo class]])
+ {
+ return (ICETCPEndpointInfo<ICEEndpointInfo>*)info;
+ }
+ }
+ return nil;
+}
+
+static ICETCPConnectionInfo*
+getTCPConnectionInfo(ICEConnectionInfo* info)
+{
+ for(; info; info = info.underlying)
+ {
+ if([info isKindOfClass:[ICETCPConnectionInfo class]])
+ {
+ return (ICETCPConnectionInfo*)info;
+ }
+ }
+ return nil;
+}
TestInfoTestIntfPrx*
infoAllTests(id<ICECommunicator> communicator)
@@ -25,8 +50,9 @@ infoAllTests(id<ICECommunicator> communicator)
ICEEndpointSeq* endps = [p1 ice_getEndpoints];
id<ICEEndpoint> endpoint = [endps objectAtIndex:0];
- ICEIPEndpointInfo<ICEEndpointInfo>* ipEndpoint = (ICEIPEndpointInfo<ICEEndpointInfo>*)[endpoint getInfo];
- test([ipEndpoint isKindOfClass:[ICEIPEndpointInfo class]]);
+ ICEEndpointInfo<ICEEndpointInfo>* info = [endpoint getInfo];
+ ICETCPEndpointInfo<ICEEndpointInfo>* ipEndpoint = getTCPEndpointInfo(info);
+ test([ipEndpoint isKindOfClass:[ICETCPEndpointInfo class]]);
test([[ipEndpoint host] isEqualToString:@"tcphost"]);
test(ipEndpoint.port == 10000);
test(ipEndpoint.timeout == 1200);
@@ -38,11 +64,10 @@ infoAllTests(id<ICECommunicator> communicator)
([ipEndpoint type] == ICEWSEndpointType && ![ipEndpoint secure]) ||
([ipEndpoint type] == ICEWSSEndpointType && [ipEndpoint secure]));
- test(([ipEndpoint type] == ICETCPEndpointType && [ipEndpoint isKindOfClass:[ICETCPEndpointInfo class]]) ||
- ([ipEndpoint type] == ICESSLEndpointType && [ipEndpoint isKindOfClass:[ICESSLEndpointInfo class]]) ||
- ([ipEndpoint type] == ICEWSEndpointType && [ipEndpoint isKindOfClass:[ICEWSEndpointInfo class]]) ||
- ([ipEndpoint type] == ICEWSSEndpointType && [ipEndpoint isKindOfClass:[ICESSLWSSEndpointInfo class]]));
-
+ test(([ipEndpoint type] == ICETCPEndpointType && [info isKindOfClass:[ICETCPEndpointInfo class]]) ||
+ ([ipEndpoint type] == ICESSLEndpointType && [info isKindOfClass:[ICESSLEndpointInfo class]]) ||
+ ([ipEndpoint type] == ICEWSEndpointType && [info isKindOfClass:[ICEWSEndpointInfo class]]) ||
+ ([ipEndpoint type] == ICEWSSEndpointType && [info isKindOfClass:[ICEWSEndpointInfo class]]));
endpoint = [endps objectAtIndex:1];
ICEUDPEndpointInfo<ICEEndpointInfo>* udpEndpoint = (ICEUDPEndpointInfo<ICEEndpointInfo>*)[endpoint getInfo];
@@ -78,8 +103,8 @@ infoAllTests(id<ICECommunicator> communicator)
test([endpoints isEqualToArray:publishedEndpoints]);
id<ICEEndpoint> endpoint = [endpoints objectAtIndex:0];
- ICEIPEndpointInfo<ICEEndpointInfo>* ipEndpoint = (ICEIPEndpointInfo<ICEEndpointInfo>*)[endpoint getInfo];
- test([ipEndpoint isKindOfClass:[ICEIPEndpointInfo class]]);
+ ICETCPEndpointInfo<ICEEndpointInfo>* ipEndpoint = getTCPEndpointInfo([endpoint getInfo]);
+ test([ipEndpoint isKindOfClass:[ICETCPEndpointInfo class]]);
test([ipEndpoint type] == ICETCPEndpointType || [ipEndpoint type] == ICESSLEndpointType ||
[ipEndpoint type] == ICEWSEndpointType || [ipEndpoint type] == ICEWSSEndpointType);
test([ipEndpoint.host isEqualToString:defaultHost]);
@@ -107,11 +132,11 @@ infoAllTests(id<ICECommunicator> communicator)
for(id object in endpoints)
{
endpoint = (id<ICEEndpoint>)object;
- ipEndpoint = (ICEIPEndpointInfo<ICEEndpointInfo>*)[endpoint getInfo];
+ ipEndpoint = getTCPEndpointInfo([endpoint getInfo]);
test(ipEndpoint.port == 12020);
}
- ipEndpoint = (ICEIPEndpointInfo<ICEEndpointInfo>*)[[publishedEndpoints objectAtIndex:0] getInfo];
+ ipEndpoint = getTCPEndpointInfo([[publishedEndpoints objectAtIndex:0] getInfo]);
test([ipEndpoint.host isEqualToString:@"127.0.0.1"]);
test(ipEndpoint.port == 12020);
@@ -124,9 +149,9 @@ infoAllTests(id<ICECommunicator> communicator)
tprintf("test connection endpoint information... ");
{
- ICEEndpointInfo* info = [[[base ice_getConnection] getEndpoint] getInfo];
- ICEIPEndpointInfo* ipinfo = (ICEIPEndpointInfo*)info;
- test([ipinfo isKindOfClass:[ICEIPEndpointInfo class]]);
+ ICEEndpointInfo<ICEEndpointInfo>* info = [[[base ice_getConnection] getEndpoint] getInfo];
+ ICETCPEndpointInfo* ipinfo = getTCPEndpointInfo(info);
+ test([ipinfo isKindOfClass:[ICETCPEndpointInfo class]]);
test(ipinfo.port == 12010);
test(!ipinfo.compress);
test([ipinfo.host isEqualToString:defaultHost]);
@@ -149,42 +174,32 @@ infoAllTests(id<ICECommunicator> communicator)
id<ICEConnection> connection = [base ice_getConnection];
[connection setBufferSize:1024 sndSize:2048];
- ICEIPConnectionInfo* info = (ICEIPConnectionInfo*)[connection getInfo];
- test([info isKindOfClass:[ICEIPConnectionInfo class]]);
- test(!info.incoming);
- test([info.adapterName isEqualToString:@""]);
- test(info.localPort > 0);
- test(info.remotePort == 12010);
+ ICEConnectionInfo* info = [connection getInfo];
+ ICETCPConnectionInfo* ipinfo = getTCPConnectionInfo([connection getInfo]);
+ test([ipinfo isKindOfClass:[ICETCPConnectionInfo class]]);
+ test(!ipinfo.incoming);
+ test([ipinfo.adapterName isEqualToString:@""]);
+ test(ipinfo.localPort > 0);
+ test(ipinfo.remotePort == 12010);
if([defaultHost isEqualToString:@"127.0.0.1"])
{
- test([info.remoteAddress isEqualToString:defaultHost]);
- test([info.localAddress isEqualToString:defaultHost]);
+ test([ipinfo.remoteAddress isEqualToString:defaultHost]);
+ test([ipinfo.localAddress isEqualToString:defaultHost]);
}
- test(info.rcvSize >= 1024);
- test(info.sndSize >= 2048);
+ test(ipinfo.rcvSize >= 1024);
+ test(ipinfo.sndSize >= 2048);
ICEContext* ctx = [testIntf getConnectionInfoAsContext];
test([[ctx objectForKey:@"incoming"] isEqualToString:@"true"]);
test([[ctx objectForKey:@"adapterName"] isEqualToString:@"TestAdapter"]);
- test([[ctx objectForKey:@"remoteAddress"] isEqualToString:info.remoteAddress]);
- test([[ctx objectForKey:@"localAddress"] isEqualToString:info.localAddress]);
- test([[ctx objectForKey:@"remotePort"] intValue] == info.localPort);
- test([[ctx objectForKey:@"localPort"] intValue] == info.remotePort);
+ test([[ctx objectForKey:@"remoteAddress"] isEqualToString:ipinfo.remoteAddress]);
+ test([[ctx objectForKey:@"localAddress"] isEqualToString:ipinfo.localAddress]);
+ test([[ctx objectForKey:@"remotePort"] intValue] == ipinfo.localPort);
+ test([[ctx objectForKey:@"localPort"] intValue] == ipinfo.remotePort);
- if([info isKindOfClass:[ICEWSConnectionInfo class]] || [info isKindOfClass:[ICESSLWSSConnectionInfo class]])
+ if([info isKindOfClass:[ICEWSConnectionInfo class]])
{
- ICEHeaderDict* headers;
- if([info isKindOfClass:[ICEWSConnectionInfo class]])
- {
- ICEWSConnectionInfo* wsinfo = (ICEWSConnectionInfo*)info;
- headers = wsinfo.headers;
- }
-
- if([info isKindOfClass:[ICESSLWSSConnectionInfo class]])
- {
- ICESSLWSSConnectionInfo* wssinfo = (ICESSLWSSConnectionInfo*)info;
- headers = wssinfo.headers;
- }
+ ICEHeaderDict* headers = ((ICEWSConnectionInfo*)info).headers;
test([[headers objectForKey:@"Upgrade"] isEqualToString:@"websocket"]);
test([[headers objectForKey:@"Connection"] isEqualToString:@"Upgrade"]);
@@ -201,19 +216,20 @@ infoAllTests(id<ICECommunicator> communicator)
connection = [[base ice_datagram] ice_getConnection];
[connection setBufferSize:2048 sndSize:1024];
- info = (ICEIPConnectionInfo*)[connection getInfo];
- test([info isKindOfClass:[ICEIPConnectionInfo class]]);
- test(!info.incoming);
- test([info.adapterName isEqualToString:@""]);
- test(info.localPort > 0);
- test(info.remotePort == 12010);
+ info = [connection getInfo];
+ test([info isKindOfClass:[ICEUDPConnectionInfo class]]);
+ ICEUDPConnectionInfo* udpinfo = (ICEUDPConnectionInfo*)info;
+ test(!udpinfo.incoming);
+ test([udpinfo.adapterName isEqualToString:@""]);
+ test(udpinfo.localPort > 0);
+ test(udpinfo.remotePort == 12010);
if([defaultHost isEqualToString:@"127.0.0.1"])
{
- test([info.remoteAddress isEqualToString:defaultHost]);
- test([info.localAddress isEqualToString:defaultHost]);
+ test([udpinfo.remoteAddress isEqualToString:defaultHost]);
+ test([udpinfo.localAddress isEqualToString:defaultHost]);
}
- test(info.rcvSize >= 2048);
- test(info.sndSize >= 1024);
+ test(udpinfo.rcvSize >= 2048);
+ test(udpinfo.sndSize >= 1024);
}
tprintf("ok\n");
diff --git a/objective-c/test/Ice/info/Client.m b/objective-c/test/Ice/info/Client.m
index 54c505400de..3b82e01aed4 100644
--- a/objective-c/test/Ice/info/Client.m
+++ b/objective-c/test/Ice/info/Client.m
@@ -29,6 +29,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/info/Server.m b/objective-c/test/Ice/info/Server.m
index 049840405e0..7472c0036ea 100644
--- a/objective-c/test/Ice/info/Server.m
+++ b/objective-c/test/Ice/info/Server.m
@@ -32,6 +32,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/info/TestI.m b/objective-c/test/Ice/info/TestI.m
index d4c8b2fc856..6d97bb20c90 100644
--- a/objective-c/test/Ice/info/TestI.m
+++ b/objective-c/test/Ice/info/TestI.m
@@ -12,8 +12,33 @@
#import <info/TestI.h>
#import <TestCommon.h>
-@implementation TestInfoTestIntfI
+static ICEIPEndpointInfo<ICEEndpointInfo>*
+getIPEndpointInfo(ICEEndpointInfo<ICEEndpointInfo>* info)
+{
+ for(; info; info = info.underlying)
+ {
+ if([info isKindOfClass:[ICEIPEndpointInfo class]])
+ {
+ return (ICEIPEndpointInfo<ICEEndpointInfo>*)info;
+ }
+ }
+ return nil;
+}
+static ICEIPConnectionInfo*
+getIPConnectionInfo(ICEConnectionInfo* info)
+{
+ for(; info; info = info.underlying)
+ {
+ if([info isKindOfClass:[ICEIPConnectionInfo class]])
+ {
+ return (ICEIPConnectionInfo*)info;
+ }
+ }
+ return nil;
+}
+
+@implementation TestInfoTestIntfI
-(void) shutdown:(ICECurrent*)c
{
@@ -33,7 +58,7 @@
[ctx setObject:[info secure] ? @"true" : @"false" forKey:@"secure"];
[ctx setObject:[NSString stringWithFormat:@"%d", [info type]] forKey:@"type"];
- ICEIPEndpointInfo* ipinfo = (ICEIPEndpointInfo*)info;
+ ICEIPEndpointInfo* ipinfo = getIPEndpointInfo(info);
[ctx setObject:ipinfo.host forKey:@"host"];
[ctx setObject:[NSString stringWithFormat:@"%d", ipinfo.port] forKey:@"port"];
@@ -52,7 +77,7 @@
ICEMutableContext* ctx = [ICEMutableContext dictionaryWithObject:[info adapterName] forKey:@"adapterName"];
[ctx setObject:info.incoming ? @"true" : @"false" forKey:@"incoming"];
- ICEIPConnectionInfo* ipinfo = (ICEIPConnectionInfo*)info;
+ ICEIPConnectionInfo* ipinfo = getIPConnectionInfo(info);
[ctx setObject:ipinfo.localAddress forKey:@"localAddress"];
[ctx setObject:[NSString stringWithFormat:@"%d", ipinfo.localPort] forKey:@"localPort"];
[ctx setObject:ipinfo.remoteAddress forKey:@"remoteAddress"];
@@ -67,14 +92,6 @@
}
}
- if([info isKindOfClass:[ICESSLWSSConnectionInfo class]])
- {
- ICESSLWSSConnectionInfo* wssinfo = (ICESSLWSSConnectionInfo*)info;
- for(NSString* key in wssinfo.headers)
- {
- [ctx setObject:[wssinfo.headers objectForKey:key] forKey:[NSString stringWithFormat:@"ws.%@", key]];
- }
- }
return ctx;
}
@end
diff --git a/objective-c/test/Ice/inheritance/Client.m b/objective-c/test/Ice/inheritance/Client.m
index 24933841667..b152a8c87bd 100644
--- a/objective-c/test/Ice/inheritance/Client.m
+++ b/objective-c/test/Ice/inheritance/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/inheritance/Collocated.m b/objective-c/test/Ice/inheritance/Collocated.m
index fc6140a8e9c..a78ab9202f3 100644
--- a/objective-c/test/Ice/inheritance/Collocated.m
+++ b/objective-c/test/Ice/inheritance/Collocated.m
@@ -32,6 +32,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/inheritance/Server.m b/objective-c/test/Ice/inheritance/Server.m
index 51dbc2ccf36..063eedd7baa 100644
--- a/objective-c/test/Ice/inheritance/Server.m
+++ b/objective-c/test/Ice/inheritance/Server.m
@@ -33,6 +33,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/interceptor/Client.m b/objective-c/test/Ice/interceptor/Client.m
index f1bf0aee1b5..af14b69d378 100644
--- a/objective-c/test/Ice/interceptor/Client.m
+++ b/objective-c/test/Ice/interceptor/Client.m
@@ -110,6 +110,13 @@ interceptorServer(int argc, char* argv[])
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
@@ -153,4 +160,3 @@ main(int argc, char* argv[])
}
return status;
}
-
diff --git a/objective-c/test/Ice/invoke/Client.m b/objective-c/test/Ice/invoke/Client.m
index 36f6392c472..ea849b154fc 100644
--- a/objective-c/test/Ice/invoke/Client.m
+++ b/objective-c/test/Ice/invoke/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/invoke/Server.m b/objective-c/test/Ice/invoke/Server.m
index 8bc22afa541..c85d3ab5923 100644
--- a/objective-c/test/Ice/invoke/Server.m
+++ b/objective-c/test/Ice/invoke/Server.m
@@ -32,6 +32,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/location/Client.m b/objective-c/test/Ice/location/Client.m
index 780d8090ca9..5b7714848be 100644
--- a/objective-c/test/Ice/location/Client.m
+++ b/objective-c/test/Ice/location/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/location/Server.m b/objective-c/test/Ice/location/Server.m
index 03f6fa5ab94..cef03f85d96 100644
--- a/objective-c/test/Ice/location/Server.m
+++ b/objective-c/test/Ice/location/Server.m
@@ -60,6 +60,13 @@ run(id<ICECommunicator> communicator, ICEInitializationData* initData)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/metrics/Client.m b/objective-c/test/Ice/metrics/Client.m
index 312b9fbe0b8..7d9d59f9ce7 100644
--- a/objective-c/test/Ice/metrics/Client.m
+++ b/objective-c/test/Ice/metrics/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/metrics/Server.m b/objective-c/test/Ice/metrics/Server.m
index bafc6e1fc4b..4f603bd3db4 100644
--- a/objective-c/test/Ice/metrics/Server.m
+++ b/objective-c/test/Ice/metrics/Server.m
@@ -42,6 +42,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/objects/Client.m b/objective-c/test/Ice/objects/Client.m
index cf6714e3859..0d2f5f3f51b 100644
--- a/objective-c/test/Ice/objects/Client.m
+++ b/objective-c/test/Ice/objects/Client.m
@@ -103,6 +103,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/objects/Collocated.m b/objective-c/test/Ice/objects/Collocated.m
index 35d3484704b..a48559da9da 100644
--- a/objective-c/test/Ice/objects/Collocated.m
+++ b/objective-c/test/Ice/objects/Collocated.m
@@ -110,6 +110,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/objects/Server.m b/objective-c/test/Ice/objects/Server.m
index 1c4eddcc377..5eef14fbbc5 100644
--- a/objective-c/test/Ice/objects/Server.m
+++ b/objective-c/test/Ice/objects/Server.m
@@ -63,6 +63,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/operations/Client.m b/objective-c/test/Ice/operations/Client.m
index 3604219f526..5ea0fca8cee 100644
--- a/objective-c/test/Ice/operations/Client.m
+++ b/objective-c/test/Ice/operations/Client.m
@@ -38,6 +38,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/operations/Collocated.m b/objective-c/test/Ice/operations/Collocated.m
index 643c1f1095e..2ee28ffb42c 100644
--- a/objective-c/test/Ice/operations/Collocated.m
+++ b/objective-c/test/Ice/operations/Collocated.m
@@ -35,6 +35,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/operations/Server.m b/objective-c/test/Ice/operations/Server.m
index 89eed817793..a952f03c4e9 100644
--- a/objective-c/test/Ice/operations/Server.m
+++ b/objective-c/test/Ice/operations/Server.m
@@ -33,6 +33,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/optional/Client.m b/objective-c/test/Ice/optional/Client.m
index 7111cef8aef..8ad1ad7cc72 100644
--- a/objective-c/test/Ice/optional/Client.m
+++ b/objective-c/test/Ice/optional/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/optional/Server.m b/objective-c/test/Ice/optional/Server.m
index fbab606f01e..2aba2329100 100644
--- a/objective-c/test/Ice/optional/Server.m
+++ b/objective-c/test/Ice/optional/Server.m
@@ -33,6 +33,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/proxy/Client.m b/objective-c/test/Ice/proxy/Client.m
index 14178c9ea27..880bef85659 100644
--- a/objective-c/test/Ice/proxy/Client.m
+++ b/objective-c/test/Ice/proxy/Client.m
@@ -29,6 +29,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/proxy/Collocated.m b/objective-c/test/Ice/proxy/Collocated.m
index b0af814ae77..73127d41aa9 100644
--- a/objective-c/test/Ice/proxy/Collocated.m
+++ b/objective-c/test/Ice/proxy/Collocated.m
@@ -33,6 +33,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/proxy/Server.m b/objective-c/test/Ice/proxy/Server.m
index f7690a9cf47..b2b5b4cea6b 100644
--- a/objective-c/test/Ice/proxy/Server.m
+++ b/objective-c/test/Ice/proxy/Server.m
@@ -33,6 +33,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/retry/Client.m b/objective-c/test/Ice/retry/Client.m
index 08ec608aa77..22529dbf861 100644
--- a/objective-c/test/Ice/retry/Client.m
+++ b/objective-c/test/Ice/retry/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/retry/Collocated.m b/objective-c/test/Ice/retry/Collocated.m
index 8a8e88e5696..e83504609b5 100644
--- a/objective-c/test/Ice/retry/Collocated.m
+++ b/objective-c/test/Ice/retry/Collocated.m
@@ -34,6 +34,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/retry/Server.m b/objective-c/test/Ice/retry/Server.m
index f0f53e8c737..84ea09af9ec 100644
--- a/objective-c/test/Ice/retry/Server.m
+++ b/objective-c/test/Ice/retry/Server.m
@@ -33,6 +33,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/servantLocator/Client.m b/objective-c/test/Ice/servantLocator/Client.m
index efe1aee6734..f0af07ce1b9 100644
--- a/objective-c/test/Ice/servantLocator/Client.m
+++ b/objective-c/test/Ice/servantLocator/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/servantLocator/Collocated.m b/objective-c/test/Ice/servantLocator/Collocated.m
index 849e735c624..6d8478c40d9 100644
--- a/objective-c/test/Ice/servantLocator/Collocated.m
+++ b/objective-c/test/Ice/servantLocator/Collocated.m
@@ -82,6 +82,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
@autoreleasepool
{
int status;
diff --git a/objective-c/test/Ice/servantLocator/Server.m b/objective-c/test/Ice/servantLocator/Server.m
index 7180b71d6f5..922e19b31d3 100644
--- a/objective-c/test/Ice/servantLocator/Server.m
+++ b/objective-c/test/Ice/servantLocator/Server.m
@@ -83,6 +83,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
@autoreleasepool
{
int status;
diff --git a/objective-c/test/Ice/services/Client.m b/objective-c/test/Ice/services/Client.m
index 478eb72cd63..c7bd1081dde 100644
--- a/objective-c/test/Ice/services/Client.m
+++ b/objective-c/test/Ice/services/Client.m
@@ -26,6 +26,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/slicing/exceptions/Client.m b/objective-c/test/Ice/slicing/exceptions/Client.m
index 24f7bef2e2d..815f699149c 100644
--- a/objective-c/test/Ice/slicing/exceptions/Client.m
+++ b/objective-c/test/Ice/slicing/exceptions/Client.m
@@ -27,8 +27,15 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
- int status;
- @autoreleasepool
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
+ int status;
+ @autoreleasepool
{
id<ICECommunicator> communicator = nil;
@try
diff --git a/objective-c/test/Ice/slicing/exceptions/Server.m b/objective-c/test/Ice/slicing/exceptions/Server.m
index 3cf75e218cc..3df6ff8e516 100644
--- a/objective-c/test/Ice/slicing/exceptions/Server.m
+++ b/objective-c/test/Ice/slicing/exceptions/Server.m
@@ -34,6 +34,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/slicing/objects/Client.m b/objective-c/test/Ice/slicing/objects/Client.m
index 9a9dd84e158..3dffd605226 100644
--- a/objective-c/test/Ice/slicing/objects/Client.m
+++ b/objective-c/test/Ice/slicing/objects/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/slicing/objects/Server.m b/objective-c/test/Ice/slicing/objects/Server.m
index 53eaa9e069b..d913f6c1781 100644
--- a/objective-c/test/Ice/slicing/objects/Server.m
+++ b/objective-c/test/Ice/slicing/objects/Server.m
@@ -35,6 +35,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/stream/Client.m b/objective-c/test/Ice/stream/Client.m
index 3a9dff258c6..b257326f30b 100644
--- a/objective-c/test/Ice/stream/Client.m
+++ b/objective-c/test/Ice/stream/Client.m
@@ -920,6 +920,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/timeout/Client.m b/objective-c/test/Ice/timeout/Client.m
index 81f842d6e98..ab3f10601f3 100644
--- a/objective-c/test/Ice/timeout/Client.m
+++ b/objective-c/test/Ice/timeout/Client.m
@@ -27,6 +27,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Ice/timeout/Server.m b/objective-c/test/Ice/timeout/Server.m
index a9bd0555cba..25662b9a00d 100644
--- a/objective-c/test/Ice/timeout/Server.m
+++ b/objective-c/test/Ice/timeout/Server.m
@@ -33,6 +33,13 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#if TARGET_OS_IPHONE
+ ICEregisterIceIAP(YES);
+#endif
+#endif
+
int status;
@autoreleasepool
{
diff --git a/objective-c/test/Slice/keyword/Client.m b/objective-c/test/Slice/keyword/Client.m
index 1cbb1e88218..a4bbb699d6e 100644
--- a/objective-c/test/Slice/keyword/Client.m
+++ b/objective-c/test/Slice/keyword/Client.m
@@ -176,6 +176,10 @@ run(id<ICECommunicator> communicator)
int
main(int argc, char* argv[])
{
+#ifdef ICE_STATIC_LIBS
+ ICEregisterIceSSL(YES);
+#endif
+
int status;
@autoreleasepool
{
@@ -213,4 +217,3 @@ main(int argc, char* argv[])
}
return status;
}
-
diff --git a/objective-c/test/ios/Objective-C Test Suite.xcodeproj/project.pbxproj b/objective-c/test/ios/Objective-C Test Suite.xcodeproj/project.pbxproj
index 1ea8bb86d52..70826cd5ace 100755
--- a/objective-c/test/ios/Objective-C Test Suite.xcodeproj/project.pbxproj
+++ b/objective-c/test/ios/Objective-C Test Suite.xcodeproj/project.pbxproj
@@ -24,8 +24,6 @@
140A392F122CF11300E1931D /* Server.m in Sources */ = {isa = PBXBuildFile; fileRef = 140A392A122CF11300E1931D /* Server.m */; };
140A3930122CF11300E1931D /* AllTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 140A392B122CF11300E1931D /* AllTests.m */; };
140A3931122CF11300E1931D /* AMITest.ice in Sources */ = {isa = PBXBuildFile; fileRef = 140A392C122CF11300E1931D /* AMITest.ice */; };
- 14103B0C1CF892720097DE5A /* ExternalAccessory.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14103B0B1CF892720097DE5A /* ExternalAccessory.framework */; };
- 14103B0D1CF8927D0097DE5A /* ExternalAccessory.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14103B0B1CF892720097DE5A /* ExternalAccessory.framework */; };
1450A1091ABC09B400A71895 /* BatchOnewaysAMI.m in Sources */ = {isa = PBXBuildFile; fileRef = 1450A1081ABC09B400A71895 /* BatchOnewaysAMI.m */; };
1450A10A1ABC09B400A71895 /* BatchOnewaysAMI.m in Sources */ = {isa = PBXBuildFile; fileRef = 1450A1081ABC09B400A71895 /* BatchOnewaysAMI.m */; };
14532D321761D39700176FE1 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
@@ -510,7 +508,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 14103B0D1CF8927D0097DE5A /* ExternalAccessory.framework in Frameworks */,
14532DC31761D39700176FE1 /* UIKit.framework in Frameworks */,
14532DC41761D39700176FE1 /* Security.framework in Frameworks */,
14532DC51761D39700176FE1 /* CFNetwork.framework in Frameworks */,
@@ -522,7 +519,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 14103B0C1CF892720097DE5A /* ExternalAccessory.framework in Frameworks */,
1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */,
344126380FD8E8EA00C8D69C /* Security.framework in Frameworks */,
344126390FD8E8EA00C8D69C /* CFNetwork.framework in Frameworks */,
diff --git a/php/src/php5/Connection.cpp b/php/src/php5/Connection.cpp
index c4bab84d404..eac54c0fe6c 100644
--- a/php/src/php5/Connection.cpp
+++ b/php/src/php5/Connection.cpp
@@ -29,7 +29,6 @@ static zend_class_entry* tcpConnectionInfoClassEntry = 0;
static zend_class_entry* udpConnectionInfoClassEntry = 0;
static zend_class_entry* wsConnectionInfoClassEntry = 0;
static zend_class_entry* sslConnectionInfoClassEntry = 0;
-static zend_class_entry* wssConnectionInfoClassEntry = 0;
//
// Ice::Connection support.
@@ -512,6 +511,8 @@ IcePHP::connectionInit(TSRMLS_D)
ce.create_object = handleConnectionInfoAlloc;
connectionInfoClassEntry = zend_register_internal_class(&ce TSRMLS_CC);
memcpy(&_connectionInfoHandlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ zend_declare_property_null(connectionInfoClassEntry, STRCAST("underlying"), sizeof("underlying") - 1,
+ ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_bool(connectionInfoClassEntry, STRCAST("incoming"), sizeof("incoming") - 1, 0,
ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_string(connectionInfoClassEntry, STRCAST("adapterName"), sizeof("adapterName") - 1,
@@ -571,7 +572,7 @@ IcePHP::connectionInit(TSRMLS_D)
INIT_CLASS_ENTRY(ce, "Ice_WSConnectionInfo", NULL);
#endif
ce.create_object = handleConnectionInfoAlloc;
- wsConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC);
+ wsConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry, NULL TSRMLS_CC);
zend_declare_property_string(wsConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1,
STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
@@ -584,7 +585,7 @@ IcePHP::connectionInit(TSRMLS_D)
INIT_CLASS_ENTRY(ce, "Ice_SSLConnectionInfo", NULL);
#endif
ce.create_object = handleConnectionInfoAlloc;
- sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC);
+ sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry, NULL TSRMLS_CC);
zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("cipher"), sizeof("cipher") - 1,
STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("certs"), sizeof("certs") - 1,
@@ -592,20 +593,6 @@ IcePHP::connectionInit(TSRMLS_D)
zend_declare_property_bool(sslConnectionInfoClassEntry, STRCAST("verified"), sizeof("verified") - 1, 0,
ZEND_ACC_PUBLIC TSRMLS_CC);
- //
- // Register the WSConnectionInfo class.
- //
-#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSConnectionInfo", NULL);
-#else
- INIT_CLASS_ENTRY(ce, "Ice_WSSConnectionInfo", NULL);
-#endif
- ce.create_object = handleConnectionInfoAlloc;
- wssConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, sslConnectionInfoClassEntry, NULL TSRMLS_CC);
- zend_declare_property_string(wssConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1,
- STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
-
-
return true;
}
@@ -653,6 +640,12 @@ IcePHP::fetchConnection(zval* zv, Ice::ConnectionPtr& connection TSRMLS_DC)
bool
IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC)
{
+ if(!p)
+ {
+ ZVAL_NULL(zv);
+ return true;
+ }
+
int status;
if(Ice::WSConnectionInfoPtr::dynamicCast(p))
{
@@ -674,7 +667,12 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC
}
else if(Ice::TCPConnectionInfoPtr::dynamicCast(p))
{
- status = object_init_ex(zv, tcpConnectionInfoClassEntry);
+ Ice::TCPConnectionInfoPtr info = Ice::TCPConnectionInfoPtr::dynamicCast(p);
+ if((status = object_init_ex(zv, tcpConnectionInfoClassEntry)) == SUCCESS)
+ {
+ add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(info->rcvSize));
+ add_property_long(zv, STRCAST("sndSize"), static_cast<long>(info->sndSize));
+ }
}
else if(Ice::UDPConnectionInfoPtr::dynamicCast(p))
{
@@ -683,24 +681,8 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC
{
add_property_string(zv, STRCAST("mcastAddress"), const_cast<char*>(info->mcastAddress.c_str()), 1);
add_property_long(zv, STRCAST("mcastPort"), static_cast<long>(info->mcastPort));
- }
- }
- else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p))
- {
- IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(p);
- if((status = object_init_ex(zv, wssConnectionInfoClassEntry)) == SUCCESS)
- {
- zval* zmap;
- MAKE_STD_ZVAL(zmap);
- AutoDestroy mapDestroyer(zmap);
- if(createStringMap(zmap, info->headers TSRMLS_CC))
- {
- add_property_zval(zv, STRCAST("headers"), zmap);
- }
- else
- {
- return false;
- }
+ add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(info->rcvSize));
+ add_property_long(zv, STRCAST("sndSize"), static_cast<long>(info->sndSize));
}
}
else if(IceSSL::ConnectionInfoPtr::dynamicCast(p))
@@ -750,6 +732,15 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC
add_property_long(zv, STRCAST("remotePort"), static_cast<long>(info->remotePort));
}
+ zval* underlying;
+ MAKE_STD_ZVAL(underlying);
+ AutoDestroy underlyingDestroyer(underlying);
+ if(!createConnectionInfo(underlying, p->underlying TSRMLS_CC))
+ {
+ runtimeError("unable to initialize connection info" TSRMLS_CC);
+ return false;
+ }
+ add_property_zval(zv, STRCAST("underlying"), underlying);
add_property_bool(zv, STRCAST("incoming"), p->incoming ? 1 : 0);
add_property_string(zv, STRCAST("adapterName"), const_cast<char*>(p->adapterName.c_str()), 1);
add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(p->rcvSize));
diff --git a/php/src/php5/Endpoint.cpp b/php/src/php5/Endpoint.cpp
index f9f0ca00c26..831f602125d 100644
--- a/php/src/php5/Endpoint.cpp
+++ b/php/src/php5/Endpoint.cpp
@@ -28,7 +28,6 @@ static zend_class_entry* udpEndpointInfoClassEntry = 0;
static zend_class_entry* wsEndpointInfoClassEntry = 0;
static zend_class_entry* opaqueEndpointInfoClassEntry = 0;
static zend_class_entry* sslEndpointInfoClassEntry = 0;
-static zend_class_entry* wssEndpointInfoClassEntry = 0;
//
// Ice::Endpoint support.
@@ -307,6 +306,8 @@ IcePHP::endpointInit(TSRMLS_D)
ce.create_object = handleEndpointInfoAlloc;
endpointInfoClassEntry = zend_register_internal_class(&ce TSRMLS_CC);
memcpy(&_endpointInfoHandlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ zend_declare_property_null(endpointInfoClassEntry, STRCAST("underlying"), sizeof("underlying") - 1,
+ ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_long(endpointInfoClassEntry, STRCAST("timeout"), sizeof("timeout") - 1, 0,
ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_bool(endpointInfoClassEntry, STRCAST("compress"), sizeof("compress") - 1, 0,
@@ -364,7 +365,7 @@ IcePHP::endpointInit(TSRMLS_D)
INIT_CLASS_ENTRY(ce, "Ice_WSEndpointInfo", NULL);
#endif
ce.create_object = handleEndpointInfoAlloc;
- wsEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry, NULL TSRMLS_CC);
+ wsEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, endpointInfoClassEntry, NULL TSRMLS_CC);
zend_declare_property_string(wsEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1,
STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
@@ -392,20 +393,7 @@ IcePHP::endpointInit(TSRMLS_D)
INIT_CLASS_ENTRY(ce, "Ice_SSLEndpointInfo", NULL);
#endif
ce.create_object = handleEndpointInfoAlloc;
- sslEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry, NULL TSRMLS_CC);
-
- //
- // Define the WSSEndpointInfo class.
- //
-#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSEndpointInfo", NULL);
-#else
- INIT_CLASS_ENTRY(ce, "Ice_WSSEndpointInfo", NULL);
-#endif
- ce.create_object = handleEndpointInfoAlloc;
- wssEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, sslEndpointInfoClassEntry, NULL TSRMLS_CC);
- zend_declare_property_string(wssEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1,
- STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC);
+ sslEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, endpointInfoClassEntry, NULL TSRMLS_CC);
return true;
}
@@ -454,6 +442,12 @@ IcePHP::fetchEndpoint(zval* zv, Ice::EndpointPtr& endpoint TSRMLS_DC)
bool
IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p TSRMLS_DC)
{
+ if(!p)
+ {
+ ZVAL_NULL(zv);
+ return true;
+ }
+
int status;
if(Ice::WSEndpointInfoPtr::dynamicCast(p))
{
@@ -498,14 +492,6 @@ IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p TSRMLS_DC)
zval_ptr_dtor(&rawBytes); // add_property_zval increased the refcount of rawBytes
}
}
- else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p))
- {
- IceSSL::WSSEndpointInfoPtr info = IceSSL::WSSEndpointInfoPtr::dynamicCast(p);
- if((status = object_init_ex(zv, wssEndpointInfoClassEntry)) == SUCCESS)
- {
- add_property_string(zv, STRCAST("resource"), const_cast<char*>(info->resource.c_str()), 1);
- }
- }
else if(IceSSL::EndpointInfoPtr::dynamicCast(p))
{
status = object_init_ex(zv, sslEndpointInfoClassEntry);
@@ -533,6 +519,15 @@ IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p TSRMLS_DC)
add_property_string(zv, STRCAST("sourceAddress"), const_cast<char*>(info->sourceAddress.c_str()), 1);
}
+ zval* underlying;
+ MAKE_STD_ZVAL(underlying);
+ AutoDestroy underlyingDestroyer(underlying);
+ if(!createEndpointInfo(underlying, p->underlying TSRMLS_CC))
+ {
+ runtimeError("unable to initialize endpoint info" TSRMLS_CC);
+ return false;
+ }
+ add_property_zval(zv, STRCAST("underlying"), underlying);
add_property_long(zv, STRCAST("timeout"), static_cast<long>(p->timeout));
add_property_bool(zv, STRCAST("compress"), static_cast<long>(p->compress));
diff --git a/php/src/php7/Connection.cpp b/php/src/php7/Connection.cpp
index b1942d133c0..e4231293390 100644
--- a/php/src/php7/Connection.cpp
+++ b/php/src/php7/Connection.cpp
@@ -29,7 +29,6 @@ static zend_class_entry* tcpConnectionInfoClassEntry = 0;
static zend_class_entry* udpConnectionInfoClassEntry = 0;
static zend_class_entry* wsConnectionInfoClassEntry = 0;
static zend_class_entry* sslConnectionInfoClassEntry = 0;
-static zend_class_entry* wssConnectionInfoClassEntry = 0;
//
// Ice::Connection support.
@@ -565,7 +564,7 @@ IcePHP::connectionInit(void)
INIT_CLASS_ENTRY(ce, "Ice_WSConnectionInfo", NULL);
#endif
ce.create_object = handleConnectionInfoAlloc;
- wsConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry);
+ wsConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry);
zend_declare_property_string(wsConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1,
STRCAST(""), ZEND_ACC_PUBLIC);
@@ -578,7 +577,7 @@ IcePHP::connectionInit(void)
INIT_CLASS_ENTRY(ce, "Ice_SSLConnectionInfo", NULL);
#endif
ce.create_object = handleConnectionInfoAlloc;
- sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry);
+ sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, connectionInfoClassEntry);
zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("cipher"), sizeof("cipher") - 1,
STRCAST(""), ZEND_ACC_PUBLIC);
zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("certs"), sizeof("certs") - 1,
@@ -586,19 +585,6 @@ IcePHP::connectionInit(void)
zend_declare_property_bool(sslConnectionInfoClassEntry, STRCAST("verified"), sizeof("verified") - 1, 0,
ZEND_ACC_PUBLIC);
- //
- // Register the WSConnectionInfo class.
- //
-#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSConnectionInfo", NULL);
-#else
- INIT_CLASS_ENTRY(ce, "Ice_WSSConnectionInfo", NULL);
-#endif
- ce.create_object = handleConnectionInfoAlloc;
- wssConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, sslConnectionInfoClassEntry);
- zend_declare_property_string(wssConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1,
- STRCAST(""), ZEND_ACC_PUBLIC);
-
return true;
}
@@ -647,6 +633,12 @@ IcePHP::fetchConnection(zval* zv, Ice::ConnectionPtr& connection)
bool
IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p)
{
+ if(!p)
+ {
+ ZVAL_NULL(zv);
+ return true;
+ }
+
int status;
if(Ice::WSConnectionInfoPtr::dynamicCast(p))
{
@@ -667,7 +659,12 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p)
}
else if(Ice::TCPConnectionInfoPtr::dynamicCast(p))
{
- status = object_init_ex(zv, tcpConnectionInfoClassEntry);
+ Ice::TCPConnectionInfoPtr info = Ice::TCPConnectionInfoPtr::dynamicCast(p);
+ if((status = object_init_ex(zv, tcpConnectionInfoClassEntry)) == SUCCESS)
+ {
+ add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(info->rcvSize));
+ add_property_long(zv, STRCAST("sndSize"), static_cast<long>(info->sndSize));
+ }
}
else if(Ice::UDPConnectionInfoPtr::dynamicCast(p))
{
@@ -676,23 +673,8 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p)
{
add_property_string(zv, STRCAST("mcastAddress"), const_cast<char*>(info->mcastAddress.c_str()));
add_property_long(zv, STRCAST("mcastPort"), static_cast<long>(info->mcastPort));
- }
- }
- else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p))
- {
- IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(p);
- if((status = object_init_ex(zv, wssConnectionInfoClassEntry)) == SUCCESS)
- {
- zval zmap;
- AutoDestroy mapDestroyer(&zmap);
- if(createStringMap(&zmap, info->headers))
- {
- add_property_zval(zv, STRCAST("headers"), &zmap);
- }
- else
- {
- return false;
- }
+ add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(info->rcvSize));
+ add_property_long(zv, STRCAST("sndSize"), static_cast<long>(info->sndSize));
}
}
else if(IceSSL::ConnectionInfoPtr::dynamicCast(p))
@@ -741,10 +723,16 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p)
add_property_long(zv, STRCAST("remotePort"), static_cast<long>(info->remotePort));
}
+ zval underlying;
+ if(!createConnectionInfo(&underlying, p->underlying TSRMLS_CC))
+ {
+ runtimeError("unable to initialize connection info" TSRMLS_CC);
+ return false;
+ }
+ add_property_zval(zv, STRCAST("underlying"), &underlying);
+ zval_ptr_dtor(&underlying); // add_property_zval increased the refcount of underlying
add_property_bool(zv, STRCAST("incoming"), p->incoming ? 1 : 0);
add_property_string(zv, STRCAST("adapterName"), const_cast<char*>(p->adapterName.c_str()));
- add_property_long(zv, STRCAST("rcvSize"), static_cast<long>(p->rcvSize));
- add_property_long(zv, STRCAST("sndSize"), static_cast<long>(p->sndSize));
Wrapper<Ice::ConnectionInfoPtr>* obj = Wrapper<Ice::ConnectionInfoPtr>::extract(zv);
assert(obj);
diff --git a/php/src/php7/Endpoint.cpp b/php/src/php7/Endpoint.cpp
index 31747200dc7..e15b24bdf17 100644
--- a/php/src/php7/Endpoint.cpp
+++ b/php/src/php7/Endpoint.cpp
@@ -28,7 +28,6 @@ static zend_class_entry* udpEndpointInfoClassEntry = 0;
static zend_class_entry* wsEndpointInfoClassEntry = 0;
static zend_class_entry* opaqueEndpointInfoClassEntry = 0;
static zend_class_entry* sslEndpointInfoClassEntry = 0;
-static zend_class_entry* wssEndpointInfoClassEntry = 0;
//
// Ice::Endpoint support.
@@ -358,7 +357,7 @@ IcePHP::endpointInit(void)
INIT_CLASS_ENTRY(ce, "Ice_WSEndpointInfo", NULL);
#endif
ce.create_object = handleEndpointInfoAlloc;
- wsEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry);
+ wsEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, endpointInfoClassEntry);
zend_declare_property_string(wsEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1,
STRCAST(""), ZEND_ACC_PUBLIC);
@@ -386,20 +385,7 @@ IcePHP::endpointInit(void)
INIT_CLASS_ENTRY(ce, "Ice_SSLEndpointInfo", NULL);
#endif
ce.create_object = handleEndpointInfoAlloc;
- sslEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry);
-
- //
- // Define the WSSEndpointInfo class.
- //
-#ifdef ICEPHP_USE_NAMESPACES
- INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSEndpointInfo", NULL);
-#else
- INIT_CLASS_ENTRY(ce, "Ice_WSSEndpointInfo", NULL);
-#endif
- ce.create_object = handleEndpointInfoAlloc;
- wssEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, sslEndpointInfoClassEntry);
- zend_declare_property_string(wssEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1,
- STRCAST(""), ZEND_ACC_PUBLIC);
+ sslEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, endpointInfoClassEntry);
return true;
}
@@ -448,6 +434,12 @@ IcePHP::fetchEndpoint(zval* zv, Ice::EndpointPtr& endpoint)
bool
IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p)
{
+ if(!p)
+ {
+ ZVAL_NULL(zv);
+ return true;
+ }
+
int status;
if(Ice::WSEndpointInfoPtr::dynamicCast(p))
{
@@ -490,14 +482,6 @@ IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p)
zval_ptr_dtor(&rawBytes); // add_property_zval increased the refcount of rawBytes
}
}
- else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p))
- {
- IceSSL::WSSEndpointInfoPtr info = IceSSL::WSSEndpointInfoPtr::dynamicCast(p);
- if((status = object_init_ex(zv, wssEndpointInfoClassEntry)) == SUCCESS)
- {
- add_property_string(zv, STRCAST("resource"), const_cast<char*>(info->resource.c_str()));
- }
- }
else if(IceSSL::EndpointInfoPtr::dynamicCast(p))
{
status = object_init_ex(zv, sslEndpointInfoClassEntry);
@@ -525,6 +509,14 @@ IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p)
add_property_string(zv, STRCAST("sourceAddress"), const_cast<char*>(info->sourceAddress.c_str()));
}
+ zval underlying;
+ if(!createEndpointInfo(&underlying, p->underlying TSRMLS_CC))
+ {
+ runtimeError("unable to initialize endpoint info" TSRMLS_CC);
+ return false;
+ }
+ add_property_zval(zv, STRCAST("underlying"), &underlying);
+ zval_ptr_dtor(&underlying); // add_property_zval increased the refcount of underlying
add_property_long(zv, STRCAST("timeout"), static_cast<long>(p->timeout));
add_property_bool(zv, STRCAST("compress"), static_cast<long>(p->compress));
diff --git a/php/test/Ice/info/Client.php b/php/test/Ice/info/Client.php
index 64632cbd616..c17d3cc819b 100644
--- a/php/test/Ice/info/Client.php
+++ b/php/test/Ice/info/Client.php
@@ -30,11 +30,38 @@ function test($b)
}
}
+function getTCPEndpointInfo($i)
+{
+ global $NS;
+ $tcpEndpointInfoClass = $NS ? "Ice\\TCPEndpointInfo" : "Ice_TCPEndpointInfo";
+ while($i)
+ {
+ if($i instanceof $tcpEndpointInfoClass)
+ {
+ return $i;
+ }
+ $i = $i->underlying;
+ }
+}
+
+function getTCPConnectionInfo($i)
+{
+ global $NS;
+ $ipConnectionInfoClass = $NS ? "Ice\\TCPConnectionInfo" : "Ice_TCPConnectionInfo";
+ while($i)
+ {
+ if($i instanceof $ipConnectionInfoClass)
+ {
+ return $i;
+ }
+ $i = $i->underlying;
+ }
+}
+
function allTests($communicator)
{
global $NS;
- $ipEndpointInfoClass = $NS ? "Ice\\IPEndpointInfo" : "Ice_IPEndpointInfo";
$tcpEndpointType = $NS ? constant("Ice\\TCPEndpointType") : constant("Ice_TCPEndpointType");
$tcpEndpointInfoClass = $NS ? "Ice\\TCPEndpointInfo" : "Ice_TCPEndpointInfo";
$udpEndpointType = $NS ? constant("Ice\\UDPEndpointType") : constant("Ice_UDPEndpointType");
@@ -58,22 +85,23 @@ function allTests($communicator)
$endps = $p1->ice_getEndpoints();
- $ipEndpoint = $endps[0]->getInfo();
- test($ipEndpoint instanceof $ipEndpointInfoClass);
- 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() == $tcpEndpointType && !$ipEndpoint->secure()) ||
- ($ipEndpoint->type() == $sslEndpointType && $ipEndpoint->secure()) ||
- ($ipEndpoint->type() == $wsEndpointType && !$ipEndpoint->secure()) ||
- ($ipEndpoint->type() == $wssEndpointType && $ipEndpoint->secure()));
- test(($ipEndpoint->type() == $tcpEndpointType && ($ipEndpoint instanceof $tcpEndpointInfoClass)) ||
- ($ipEndpoint->type() == $sslEndpointType && ($ipEndpoint instanceof $sslEndpointInfoClass)) ||
- ($ipEndpoint->type() == $wsEndpointType && ($ipEndpoint instanceof $wsEndpointInfoClass)) ||
- ($ipEndpoint->type() == $wssEndpointType && ($ipEndpoint instanceof $wssEndpointInfoClass)));
+ $endpoint = $endps[0]->getInfo();
+ $tcpEndpoint = getTCPEndpointInfo($endpoint);
+ test($tcpEndpoint instanceof $tcpEndpointInfoClass);
+ test($tcpEndpoint->host == "tcphost");
+ test($tcpEndpoint->port == 10000);
+ test($tcpEndpoint->timeout == 1200);
+ test($tcpEndpoint->sourceAddress == "10.10.10.10");
+ test($tcpEndpoint->compress);
+ test(!$tcpEndpoint->datagram());
+ test(($tcpEndpoint->type() == $tcpEndpointType && !$tcpEndpoint->secure()) ||
+ ($tcpEndpoint->type() == $sslEndpointType && $tcpEndpoint->secure()) ||
+ ($tcpEndpoint->type() == $wsEndpointType && !$tcpEndpoint->secure()) ||
+ ($tcpEndpoint->type() == $wssEndpointType && $tcpEndpoint->secure()));
+ test(($tcpEndpoint->type() == $tcpEndpointType && ($endpoint instanceof $tcpEndpointInfoClass)) ||
+ ($tcpEndpoint->type() == $sslEndpointType && ($endpoint instanceof $sslEndpointInfoClass)) ||
+ ($tcpEndpoint->type() == $wsEndpointType && ($endpoint instanceof $wsEndpointInfoClass)) ||
+ ($tcpEndpoint->type() == $wssEndpointType && ($endpoint instanceof $wsEndpointInfoClass)));
$udpEndpoint = $endps[1]->getInfo();
test($udpEndpoint instanceof $udpEndpointInfoClass);
@@ -100,14 +128,14 @@ function allTests($communicator)
echo "test connection endpoint information... ";
flush();
{
- $ipinfo = $base->ice_getConnection()->getEndpoint()->getInfo();
- test($ipinfo instanceof $ipEndpointInfoClass);
- test($ipinfo->port == 12010);
- test(!$ipinfo->compress);
- test($ipinfo->host == $defaultHost);
+ $tcpinfo = getTCPEndpointInfo($base->ice_getConnection()->getEndpoint()->getInfo());
+ test($tcpinfo instanceof $tcpEndpointInfoClass);
+ test($tcpinfo->port == 12010);
+ test(!$tcpinfo->compress);
+ test($tcpinfo->host == $defaultHost);
$ctx = $testIntf->getEndpointInfoAsContext();
- test($ctx["host"] == $ipinfo->host);
+ test($ctx["host"] == $tcpinfo->host);
test($ctx["compress"] == "false");
test($ctx["port"] > 0);
@@ -121,38 +149,37 @@ function allTests($communicator)
echo "testing connection information... ";
flush();
{
- $ipConnectionInfoClass = $NS ? "Ice\\IPConnectionInfo" : "Ice_IPConnectionInfo";
+ $ipConnectionInfoClass = $NS ? "Ice\\TCPConnectionInfo" : "Ice_TCPConnectionInfo";
$wsConnectionInfoClass = $NS ? "Ice\\WSConnectionInfo" : "Ice_WSConnectionInfo";
- $wssConnectionInfoClass = $NS ? "Ice\\WSSConnectionInfo" : "Ice_WSSConnectionInfo";
$connection = $base->ice_getConnection();
$connection->setBufferSize(1024, 2048);
$info = $connection->getInfo();
- test($info instanceof $ipConnectionInfoClass);
+ $tcpinfo = getTCPConnectionInfo($info);
+ test($tcpinfo instanceof $ipConnectionInfoClass);
test(!$info->incoming);
test(strlen($info->adapterName) == 0);
- test($info->remotePort == 12010);
+ test($tcpinfo->remotePort == 12010);
if($defaultHost == "127.0.0.1")
{
- test($info->remoteAddress == $defaultHost);
- test($info->localAddress == $defaultHost);
+ test($tcpinfo->remoteAddress == $defaultHost);
+ test($tcpinfo->localAddress == $defaultHost);
}
- test($info->rcvSize >= 1024);
- test($info->sndSize >= 2048);
+ test($tcpinfo->rcvSize >= 1024);
+ test($tcpinfo->sndSize >= 2048);
$ctx = $testIntf->getConnectionInfoAsContext();
test($ctx["incoming"] == "true");
test($ctx["adapterName"] == "TestAdapter");
- test($ctx["remoteAddress"] == $info->localAddress);
- test($ctx["localAddress"] == $info->remoteAddress);
- test($ctx["remotePort"] == $info->localPort);
- test($ctx["localPort"] == $info->remotePort);
+ test($ctx["remoteAddress"] == $tcpinfo->localAddress);
+ test($ctx["localAddress"] == $tcpinfo->remoteAddress);
+ test($ctx["remotePort"] == $tcpinfo->localPort);
+ test($ctx["localPort"] == $tcpinfo->remotePort);
if($base->ice_getConnection()->type() == "ws" || $base->ice_getConnection()->type() == "wss")
{
- test(($base->ice_getConnection()->type() == "ws" && $info instanceof $wsConnectionInfoClass) ||
- ($base->ice_getConnection()->type() == "wss" && $info instanceof $wssConnectionInfoClass));
+ test($info instanceof $wsConnectionInfoClass);
test($info->headers["Upgrade"] == "websocket");
test($info->headers["Connection"] == "Upgrade");
diff --git a/python/modules/IcePy/ConnectionInfo.cpp b/python/modules/IcePy/ConnectionInfo.cpp
index 625d0952fe5..bab845be7f0 100644
--- a/python/modules/IcePy/ConnectionInfo.cpp
+++ b/python/modules/IcePy/ConnectionInfo.cpp
@@ -54,6 +54,15 @@ connectionInfoDealloc(ConnectionInfoObject* self)
extern "C"
#endif
static PyObject*
+connectionInfoGetUnderlying(ConnectionInfoObject* self)
+{
+ return createConnectionInfo((*self->connectionInfo)->underlying);
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
connectionInfoGetIncoming(ConnectionInfoObject* self)
{
return (*self->connectionInfo)->incoming ? incTrue() : incFalse();
@@ -72,62 +81,66 @@ connectionInfoGetAdapterName(ConnectionInfoObject* self)
extern "C"
#endif
static PyObject*
-connectionInfoGetRcvSize(ConnectionInfoObject* self)
+ipConnectionInfoGetLocalAddress(ConnectionInfoObject* self)
{
- return PyLong_FromLong((*self->connectionInfo)->rcvSize);
+ Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ assert(info);
+ return createString(info->localAddress);
}
#ifdef WIN32
extern "C"
#endif
static PyObject*
-connectionInfoGetSndSize(ConnectionInfoObject* self)
+ipConnectionInfoGetLocalPort(ConnectionInfoObject* self)
{
- return PyLong_FromLong((*self->connectionInfo)->sndSize);
+ Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ assert(info);
+ return PyLong_FromLong(info->localPort);
}
#ifdef WIN32
extern "C"
#endif
static PyObject*
-ipConnectionInfoGetLocalAddress(ConnectionInfoObject* self)
+ipConnectionInfoGetRemoteAddress(ConnectionInfoObject* self)
{
Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
assert(info);
- return createString(info->localAddress);
+ return createString(info->remoteAddress);
}
#ifdef WIN32
extern "C"
#endif
static PyObject*
-ipConnectionInfoGetLocalPort(ConnectionInfoObject* self)
+ipConnectionInfoGetRemotePort(ConnectionInfoObject* self)
{
Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
assert(info);
- return PyLong_FromLong(info->localPort);
+ return PyLong_FromLong(info->remotePort);
}
#ifdef WIN32
extern "C"
#endif
static PyObject*
-ipConnectionInfoGetRemoteAddress(ConnectionInfoObject* self)
+tcpConnectionInfoGetRcvSize(ConnectionInfoObject* self)
{
- Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ Ice::TCPConnectionInfoPtr info = Ice::TCPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
assert(info);
- return createString(info->remoteAddress);
+ return PyLong_FromLong(info->rcvSize);
}
#ifdef WIN32
extern "C"
#endif
static PyObject*
-ipConnectionInfoGetRemotePort(ConnectionInfoObject* self)
+tcpConnectionInfoGetSndSize(ConnectionInfoObject* self)
{
- Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ Ice::TCPConnectionInfoPtr info = Ice::TCPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
assert(info);
- return PyLong_FromLong(info->remotePort);
+ return PyLong_FromLong(info->sndSize);
}
#ifdef WIN32
@@ -156,6 +169,28 @@ udpConnectionInfoGetMcastPort(ConnectionInfoObject* self, void* member)
extern "C"
#endif
static PyObject*
+udpConnectionInfoGetRcvSize(ConnectionInfoObject* self)
+{
+ Ice::UDPConnectionInfoPtr info = Ice::UDPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ assert(info);
+ return PyLong_FromLong(info->rcvSize);
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
+udpConnectionInfoGetSndSize(ConnectionInfoObject* self)
+{
+ Ice::UDPConnectionInfoPtr info = Ice::UDPConnectionInfoPtr::dynamicCast(*self->connectionInfo);
+ assert(info);
+ return PyLong_FromLong(info->sndSize);
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
wsConnectionInfoGetHeaders(ConnectionInfoObject* self)
{
Ice::WSConnectionInfoPtr info = Ice::WSConnectionInfoPtr::dynamicCast(*self->connectionInfo);
@@ -213,42 +248,14 @@ sslConnectionInfoGetVerified(ConnectionInfoObject* self)
return info->incoming ? incTrue() : incFalse();
}
-#ifdef WIN32
-extern "C"
-#endif
-static PyObject*
-wssConnectionInfoGetHeaders(ConnectionInfoObject* self)
-{
- IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(*self->connectionInfo);
- assert(info);
-
- PyObjectHandle result = PyDict_New();
- if(result.get())
- {
- for(Ice::HeaderDict::iterator p = info->headers.begin(); p != info->headers.end(); ++p)
- {
- PyObjectHandle key = createString(p->first);
- PyObjectHandle val = createString(p->second);
- if(!val.get() || PyDict_SetItem(result.get(), key.get(), val.get()) < 0)
- {
- return 0;
- }
- }
- }
-
- return result.release();
-}
-
static PyGetSetDef ConnectionInfoGetters[] =
{
+ { STRCAST("underlying"), reinterpret_cast<getter>(connectionInfoGetUnderlying), 0,
+ PyDoc_STR(STRCAST("get underlying connection information")), 0 },
{ STRCAST("incoming"), reinterpret_cast<getter>(connectionInfoGetIncoming), 0,
PyDoc_STR(STRCAST("whether connection is incoming")), 0 },
{ STRCAST("adapterName"), reinterpret_cast<getter>(connectionInfoGetAdapterName), 0,
PyDoc_STR(STRCAST("adapter associated the connection")), 0 },
- { STRCAST("rcvSize"), reinterpret_cast<getter>(connectionInfoGetRcvSize), 0,
- PyDoc_STR(STRCAST("receive buffer size")), 0 },
- { STRCAST("sndSize"), reinterpret_cast<getter>(connectionInfoGetSndSize), 0,
- PyDoc_STR(STRCAST("send buffer size")), 0 },
{ 0, 0 } /* sentinel */
};
@@ -265,12 +272,25 @@ static PyGetSetDef IPConnectionInfoGetters[] =
{ 0, 0 } /* sentinel */
};
+static PyGetSetDef TCPConnectionInfoGetters[] =
+{
+ { STRCAST("rcvSize"), reinterpret_cast<getter>(tcpConnectionInfoGetRcvSize), 0,
+ PyDoc_STR(STRCAST("receive buffer size")), 0 },
+ { STRCAST("sndSize"), reinterpret_cast<getter>(tcpConnectionInfoGetSndSize), 0,
+ PyDoc_STR(STRCAST("send buffer size")), 0 },
+ { 0, 0 } /* sentinel */
+};
+
static PyGetSetDef UDPConnectionInfoGetters[] =
{
{ STRCAST("mcastAddress"), reinterpret_cast<getter>(udpConnectionInfoGetMcastAddress), 0,
PyDoc_STR(STRCAST("multicast address")), 0 },
{ STRCAST("mcastPort"), reinterpret_cast<getter>(udpConnectionInfoGetMcastPort), 0,
PyDoc_STR(STRCAST("multicast port")), 0 },
+ { STRCAST("rcvSize"), reinterpret_cast<getter>(udpConnectionInfoGetRcvSize), 0,
+ PyDoc_STR(STRCAST("receive buffer size")), 0 },
+ { STRCAST("sndSize"), reinterpret_cast<getter>(udpConnectionInfoGetSndSize), 0,
+ PyDoc_STR(STRCAST("send buffer size")), 0 },
{ 0, 0 } /* sentinel */
};
@@ -292,13 +312,6 @@ static PyGetSetDef SSLConnectionInfoGetters[] =
{ 0, 0 } /* sentinel */
};
-static PyGetSetDef WSSConnectionInfoGetters[] =
-{
- { STRCAST("headers"), reinterpret_cast<getter>(wssConnectionInfoGetHeaders), 0,
- PyDoc_STR(STRCAST("request headers")), 0 },
- { 0, 0 } /* sentinel */
-};
-
namespace IcePy
{
@@ -430,7 +443,7 @@ PyTypeObject TCPConnectionInfoType =
0, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ TCPConnectionInfoGetters, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
@@ -584,53 +597,6 @@ PyTypeObject SSLConnectionInfoType =
0, /* tp_is_gc */
};
-PyTypeObject WSSConnectionInfoType =
-{
- /* The ob_type field must be initialized in the module init function
- * to be portable to Windows without using C++. */
- PyVarObject_HEAD_INIT(0, 0)
- STRCAST("IcePy.WSSConnectionInfo"),/* tp_name */
- sizeof(ConnectionInfoObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)connectionInfoDealloc, /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- WSSConnectionInfoGetters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- (newfunc)connectionInfoNew, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
-};
-
}
bool
@@ -679,7 +645,7 @@ IcePy::initConnectionInfo(PyObject* module)
return false;
}
- WSConnectionInfoType.tp_base = &IPConnectionInfoType; // Force inheritance from IPConnectionType.
+ WSConnectionInfoType.tp_base = &ConnectionInfoType; // Force inheritance from IPConnectionType.
if(PyType_Ready(&WSConnectionInfoType) < 0)
{
return false;
@@ -690,7 +656,7 @@ IcePy::initConnectionInfo(PyObject* module)
return false;
}
- SSLConnectionInfoType.tp_base = &IPConnectionInfoType; // Force inheritance from IPConnectionInfoType.
+ SSLConnectionInfoType.tp_base = &ConnectionInfoType; // Force inheritance from IPConnectionInfoType.
if(PyType_Ready(&SSLConnectionInfoType) < 0)
{
return false;
@@ -701,17 +667,6 @@ IcePy::initConnectionInfo(PyObject* module)
return false;
}
- WSSConnectionInfoType.tp_base = &SSLConnectionInfoType; // Force inheritance from IPConnectionType.
- if(PyType_Ready(&WSSConnectionInfoType) < 0)
- {
- return false;
- }
- type = &WSSConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings.
- if(PyModule_AddObject(module, STRCAST("WSSConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0)
- {
- return false;
- }
-
return true;
}
@@ -726,6 +681,12 @@ IcePy::getConnectionInfo(PyObject* obj)
PyObject*
IcePy::createConnectionInfo(const Ice::ConnectionInfoPtr& connectionInfo)
{
+ if(!connectionInfo)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
PyTypeObject* type;
if(Ice::WSConnectionInfoPtr::dynamicCast(connectionInfo))
{
@@ -739,10 +700,6 @@ IcePy::createConnectionInfo(const Ice::ConnectionInfoPtr& connectionInfo)
{
type = &UDPConnectionInfoType;
}
- else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(connectionInfo))
- {
- type = &WSSConnectionInfoType;
- }
else if(IceSSL::ConnectionInfoPtr::dynamicCast(connectionInfo))
{
type = &SSLConnectionInfoType;
diff --git a/python/modules/IcePy/EndpointInfo.cpp b/python/modules/IcePy/EndpointInfo.cpp
index 7ce8aa4c978..80001072a91 100644
--- a/python/modules/IcePy/EndpointInfo.cpp
+++ b/python/modules/IcePy/EndpointInfo.cpp
@@ -124,6 +124,15 @@ endpointInfoSecure(EndpointInfoObject* self)
extern "C"
#endif
static PyObject*
+endpointInfoGetUnderlying(EndpointInfoObject* self)
+{
+ return createEndpointInfo((*self->endpointInfo)->underlying);
+}
+
+#ifdef WIN32
+extern "C"
+#endif
+static PyObject*
endpointInfoGetTimeout(EndpointInfoObject* self)
{
return PyLong_FromLong((*self->endpointInfo)->timeout);
@@ -208,17 +217,6 @@ wsEndpointInfoGetResource(EndpointInfoObject* self)
extern "C"
#endif
static PyObject*
-wssEndpointInfoGetResource(EndpointInfoObject* self)
-{
- IceSSL::WSSEndpointInfoPtr info = IceSSL::WSSEndpointInfoPtr::dynamicCast(*self->endpointInfo);
- assert(info);
- return createString(info->resource);
-}
-
-#ifdef WIN32
-extern "C"
-#endif
-static PyObject*
opaqueEndpointInfoGetRawBytes(EndpointInfoObject* self)
{
Ice::OpaqueEndpointInfoPtr info = Ice::OpaqueEndpointInfoPtr::dynamicCast(*self->endpointInfo);
@@ -256,6 +254,8 @@ static PyMethodDef EndpointInfoMethods[] =
static PyGetSetDef EndpointInfoGetters[] =
{
+ { STRCAST("underlying"), reinterpret_cast<getter>(endpointInfoGetUnderlying), 0,
+ PyDoc_STR(STRCAST("underling endpoint information")), 0 },
{ STRCAST("timeout"), reinterpret_cast<getter>(endpointInfoGetTimeout), 0,
PyDoc_STR(STRCAST("timeout in milliseconds")), 0 },
{ STRCAST("compress"), reinterpret_cast<getter>(endpointInfoGetCompress), 0,
@@ -290,13 +290,6 @@ static PyGetSetDef WSEndpointInfoGetters[] =
{ 0, 0 } /* sentinel */
};
-static PyGetSetDef WSSEndpointInfoGetters[] =
-{
- { STRCAST("resource"), reinterpret_cast<getter>(wssEndpointInfoGetResource), 0,
- PyDoc_STR(STRCAST("resource")), 0 },
- { 0, 0 } /* sentinel */
-};
-
static PyGetSetDef OpaqueEndpointInfoGetters[] =
{
{ STRCAST("rawBytes"), reinterpret_cast<getter>(opaqueEndpointInfoGetRawBytes), 0,
@@ -361,7 +354,7 @@ PyTypeObject IPEndpointInfoType =
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
PyVarObject_HEAD_INIT(0, 0)
- STRCAST("IcePy.IPEndpointInfo"), /* tp_name */
+ STRCAST(".IPEndpointInfo"), /* tp_name */
sizeof(EndpointInfoObject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
@@ -591,53 +584,6 @@ PyTypeObject SSLEndpointInfoType =
0, /* tp_is_gc */
};
-PyTypeObject WSSEndpointInfoType =
-{
- /* The ob_type field must be initialized in the module init function
- * to be portable to Windows without using C++. */
- PyVarObject_HEAD_INIT(0, 0)
- STRCAST("IcePy.WSSEndpointInfo"), /* tp_name */
- sizeof(EndpointInfoObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */
- 0, /* tp_print */
- 0, /* tp_getattr */
- 0, /* tp_setattr */
- 0, /* tp_reserved */
- 0, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- 0, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- WSSEndpointInfoGetters, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
-};
-
PyTypeObject OpaqueEndpointInfoType =
{
/* The ob_type field must be initialized in the module init function
@@ -733,7 +679,7 @@ IcePy::initEndpointInfo(PyObject* module)
return false;
}
- WSEndpointInfoType.tp_base = &IPEndpointInfoType; // Force inheritance from IPEndpointType.
+ WSEndpointInfoType.tp_base = &EndpointInfoType; // Force inheritance from IPEndpointType.
if(PyType_Ready(&WSEndpointInfoType) < 0)
{
return false;
@@ -744,7 +690,7 @@ IcePy::initEndpointInfo(PyObject* module)
return false;
}
- SSLEndpointInfoType.tp_base = &IPEndpointInfoType; // Force inheritance from IPEndpointInfoType.
+ SSLEndpointInfoType.tp_base = &EndpointInfoType; // Force inheritance from IPEndpointInfoType.
if(PyType_Ready(&SSLEndpointInfoType) < 0)
{
return false;
@@ -755,17 +701,6 @@ IcePy::initEndpointInfo(PyObject* module)
return false;
}
- WSSEndpointInfoType.tp_base = &SSLEndpointInfoType; // Force inheritance from SSLEndpointInfoType.
- if(PyType_Ready(&WSSEndpointInfoType) < 0)
- {
- return false;
- }
- type = &WSSEndpointInfoType; // Necessary to prevent GCC's strict-alias warnings.
- if(PyModule_AddObject(module, STRCAST("WSSEndpointInfo"), reinterpret_cast<PyObject*>(type)) < 0)
- {
- return false;
- }
-
OpaqueEndpointInfoType.tp_base = &EndpointInfoType; // Force inheritance from EndpointType.
if(PyType_Ready(&OpaqueEndpointInfoType) < 0)
{
@@ -791,6 +726,12 @@ IcePy::getEndpointInfo(PyObject* obj)
PyObject*
IcePy::createEndpointInfo(const Ice::EndpointInfoPtr& endpointInfo)
{
+ if(!endpointInfo)
+ {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
PyTypeObject* type;
if(Ice::WSEndpointInfoPtr::dynamicCast(endpointInfo))
{
@@ -804,10 +745,6 @@ IcePy::createEndpointInfo(const Ice::EndpointInfoPtr& endpointInfo)
{
type = &UDPEndpointInfoType;
}
- else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(endpointInfo))
- {
- type = &WSSEndpointInfoType;
- }
else if(IceSSL::EndpointInfoPtr::dynamicCast(endpointInfo))
{
type = &SSLEndpointInfoType;
@@ -822,7 +759,6 @@ IcePy::createEndpointInfo(const Ice::EndpointInfoPtr& endpointInfo)
}
else
{
- std::cout << "CREATE" << std::endl;
type = &EndpointInfoType;
}
diff --git a/python/python/Ice.py b/python/python/Ice.py
index 3b5a4e5e5e4..c28541902ec 100644
--- a/python/python/Ice.py
+++ b/python/python/Ice.py
@@ -179,7 +179,7 @@ class Exception(Exception): # Derives from built-in base 'Exception' class.
def ice_name(self):
'''Returns the type name of this exception.'''
return self.ice_id()[2:]
-
+
def ice_id(self):
'''Returns the type id of this exception.'''
return self._ice_id
@@ -478,7 +478,6 @@ del OpaqueEndpointInfo
OpaqueEndpointInfo = IcePy.OpaqueEndpointInfo
SSLEndpointInfo = IcePy.SSLEndpointInfo
-WSSEndpointInfo = IcePy.WSSEndpointInfo
#
# Replace ConnectionInfo with our implementation.
@@ -495,7 +494,6 @@ del WSConnectionInfo
WSConnectionInfo = IcePy.WSConnectionInfo
SSLConnectionInfo = IcePy.SSLConnectionInfo
-WSSConnectionInfo = IcePy.WSSConnectionInfo
class ThreadNotification(object):
'''Base class for thread notification callbacks. A subclass must
diff --git a/python/test/Ice/info/AllTests.py b/python/test/Ice/info/AllTests.py
index b80182b5c04..a03b69ecc4d 100644
--- a/python/test/Ice/info/AllTests.py
+++ b/python/test/Ice/info/AllTests.py
@@ -13,6 +13,18 @@ def test(b):
if not b:
raise RuntimeError('test assertion failed')
+def getTCPEndpointInfo(info):
+ while(info):
+ if isinstance(info, Ice.TCPEndpointInfo):
+ return info
+ info = info.underlying
+
+def getTCPConnectionInfo(info):
+ while(info):
+ if isinstance(info, Ice.TCPConnectionInfo):
+ return info
+ info = info.underlying
+
def allTests(communicator):
sys.stdout.write("testing proxy endpoint information... ")
sys.stdout.flush()
@@ -23,22 +35,23 @@ def allTests(communicator):
endps = p1.ice_getEndpoints()
- ipEndpoint = endps[0].getInfo()
- test(isinstance(ipEndpoint, Ice.IPEndpointInfo))
- test(ipEndpoint.host == "tcphost")
- test(ipEndpoint.port == 10000)
- test(ipEndpoint.sourceAddress == "10.10.10.10")
- test(ipEndpoint.timeout == 1200)
- test(ipEndpoint.compress)
- test(not ipEndpoint.datagram())
- test((ipEndpoint.type() == Ice.TCPEndpointType and not ipEndpoint.secure()) or
- (ipEndpoint.type() == Ice.SSLEndpointType and ipEndpoint.secure()) or # SSL
- (ipEndpoint.type() == Ice.WSEndpointType and not ipEndpoint.secure()) or # WS
- (ipEndpoint.type() == Ice.WSSEndpointType and ipEndpoint.secure())) # WS
- test((ipEndpoint.type() == Ice.TCPEndpointType and isinstance(ipEndpoint, Ice.TCPEndpointInfo)) or
- (ipEndpoint.type() == Ice.SSLEndpointType and isinstance(ipEndpoint, Ice.SSLEndpointInfo)) or
- (ipEndpoint.type() == Ice.WSEndpointType and isinstance(ipEndpoint, Ice.WSEndpointInfo)) or
- (ipEndpoint.type() == Ice.WSSEndpointType and isinstance(ipEndpoint, Ice.WSSEndpointInfo)))
+ endpoint = endps[0].getInfo()
+ tcpEndpoint = getTCPEndpointInfo(endpoint)
+ test(isinstance(tcpEndpoint, Ice.TCPEndpointInfo))
+ test(tcpEndpoint.host == "tcphost")
+ test(tcpEndpoint.port == 10000)
+ test(tcpEndpoint.sourceAddress == "10.10.10.10")
+ test(tcpEndpoint.timeout == 1200)
+ test(tcpEndpoint.compress)
+ test(not tcpEndpoint.datagram())
+ test((tcpEndpoint.type() == Ice.TCPEndpointType and not tcpEndpoint.secure()) or
+ (tcpEndpoint.type() == Ice.SSLEndpointType and tcpEndpoint.secure()) or # SSL
+ (tcpEndpoint.type() == Ice.WSEndpointType and not tcpEndpoint.secure()) or # WS
+ (tcpEndpoint.type() == Ice.WSSEndpointType and tcpEndpoint.secure())) # WS
+ test((tcpEndpoint.type() == Ice.TCPEndpointType and isinstance(endpoint, Ice.TCPEndpointInfo)) or
+ (tcpEndpoint.type() == Ice.SSLEndpointType and isinstance(endpoint, Ice.SSLEndpointInfo)) or
+ (tcpEndpoint.type() == Ice.WSEndpointType and isinstance(endpoint, Ice.WSEndpointInfo)) or
+ (tcpEndpoint.type() == Ice.WSSEndpointType and isinstance(endpoint, Ice.WSEndpointInfo)))
udpEndpoint = endps[1].getInfo()
test(isinstance(udpEndpoint, Ice.UDPEndpointInfo))
@@ -71,12 +84,12 @@ def allTests(communicator):
publishedEndpoints = adapter.getPublishedEndpoints()
test(endpoints == publishedEndpoints)
- ipEndpoint = endpoints[0].getInfo()
- test(ipEndpoint.type() == Ice.TCPEndpointType or ipEndpoint.type() == 2 or ipEndpoint.type() == 4 or
- ipEndpoint.type() == 5)
- test(ipEndpoint.host == defaultHost)
- test(ipEndpoint.port > 0)
- test(ipEndpoint.timeout == 15000)
+ tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo())
+ test(tcpEndpoint.type() == Ice.TCPEndpointType or tcpEndpoint.type() == 2 or tcpEndpoint.type() == 4 or
+ tcpEndpoint.type() == 5)
+ test(tcpEndpoint.host == defaultHost)
+ test(tcpEndpoint.port > 0)
+ test(tcpEndpoint.timeout == 15000)
udpEndpoint = endpoints[1].getInfo()
test(udpEndpoint.host == defaultHost)
@@ -95,12 +108,12 @@ def allTests(communicator):
test(len(publishedEndpoints) == 1)
for i in range(0, len(endpoints)):
- ipEndpoint = endpoints[i].getInfo()
- test(ipEndpoint.port == 12020)
+ tcpEndpoint = getTCPEndpointInfo(endpoints[i].getInfo())
+ test(tcpEndpoint.port == 12020)
- ipEndpoint = publishedEndpoints[0].getInfo()
- test(ipEndpoint.host == "127.0.0.1")
- test(ipEndpoint.port == 12020)
+ tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo())
+ test(tcpEndpoint.host == "127.0.0.1")
+ test(tcpEndpoint.port == 12020)
adapter.destroy()
@@ -112,13 +125,13 @@ def allTests(communicator):
sys.stdout.write("test connection endpoint information... ")
sys.stdout.flush()
- ipinfo = base.ice_getConnection().getEndpoint().getInfo()
- test(ipinfo.port == 12010)
- test(not ipinfo.compress)
- test(ipinfo.host == defaultHost)
+ tcpinfo = getTCPEndpointInfo(base.ice_getConnection().getEndpoint().getInfo())
+ test(tcpinfo.port == 12010)
+ test(not tcpinfo.compress)
+ test(tcpinfo.host == defaultHost)
ctx = testIntf.getEndpointInfoAsContext()
- test(ctx["host"] == ipinfo.host)
+ test(ctx["host"] == tcpinfo.host)
test(ctx["compress"] == "false")
port = int(ctx["port"])
test(port > 0)
@@ -136,26 +149,26 @@ def allTests(communicator):
connection.setBufferSize(1024, 2048)
info = connection.getInfo()
+ tcpinfo = getTCPConnectionInfo(info)
test(not info.incoming)
test(len(info.adapterName) == 0)
- test(info.remotePort == 12010)
+ test(tcpinfo.remotePort == 12010)
if defaultHost == '127.0.0.1':
- test(info.remoteAddress == defaultHost)
- test(info.localAddress == defaultHost)
- test(info.rcvSize >= 1024)
- test(info.sndSize >= 2048)
+ test(tcpinfo.remoteAddress == defaultHost)
+ test(tcpinfo.localAddress == defaultHost)
+ test(tcpinfo.rcvSize >= 1024)
+ test(tcpinfo.sndSize >= 2048)
ctx = testIntf.getConnectionInfoAsContext()
test(ctx["incoming"] == "true")
test(ctx["adapterName"] == "TestAdapter")
- test(ctx["remoteAddress"] == info.localAddress)
- test(ctx["localAddress"] == info.remoteAddress)
- test(ctx["remotePort"] == str(info.localPort))
- test(ctx["localPort"] == str(info.remotePort))
+ test(ctx["remoteAddress"] == tcpinfo.localAddress)
+ test(ctx["localAddress"] == tcpinfo.remoteAddress)
+ test(ctx["remotePort"] == str(tcpinfo.localPort))
+ test(ctx["localPort"] == str(tcpinfo.remotePort))
if(base.ice_getConnection().type() == "ws" or base.ice_getConnection().type() == "wss"):
- test((base.ice_getConnection().type() == "ws" and isinstance(info, Ice.WSConnectionInfo)) or
- (base.ice_getConnection().type() == "wss" and isinstance(info, Ice.WSSConnectionInfo)))
+ test(isinstance(info, Ice.WSConnectionInfo))
test(info.headers["Upgrade"] == "websocket")
test(info.headers["Connection"] == "Upgrade")
diff --git a/python/test/Ice/info/TestI.py b/python/test/Ice/info/TestI.py
index ff98b4dd777..2325156db20 100644
--- a/python/test/Ice/info/TestI.py
+++ b/python/test/Ice/info/TestI.py
@@ -10,6 +10,18 @@
import Ice, Test
import time
+def getIPEndpointInfo(info):
+ while(info):
+ if isinstance(info, Ice.IPEndpointInfo):
+ return info
+ info = info.underlying
+
+def getIPConnectionInfo(info):
+ while(info):
+ if isinstance(info, Ice.IPConnectionInfo):
+ return info
+ info = info.underlying
+
class MyDerivedClassI(Test.TestIntf):
def __init__(self):
self.ctx = None
@@ -19,7 +31,7 @@ class MyDerivedClassI(Test.TestIntf):
def getEndpointInfoAsContext(self, current):
ctx = {}
- info = current.con.getEndpoint().getInfo()
+ info = getIPEndpointInfo(current.con.getEndpoint().getInfo())
ctx["timeout"] = str(info.timeout)
if info.compress:
ctx["compress"] = "true"
@@ -51,18 +63,19 @@ class MyDerivedClassI(Test.TestIntf):
def getConnectionInfoAsContext(self, current):
ctx = {}
info = current.con.getInfo()
+ ipinfo = getIPConnectionInfo(info)
ctx["adapterName"] = info.adapterName
if info.incoming:
ctx["incoming"] = "true"
else:
ctx["incoming"] ="false"
- ctx["localAddress"] = info.localAddress
- ctx["localPort"] = str(info.localPort)
- ctx["remoteAddress"] = info.remoteAddress
- ctx["remotePort"] = str(info.remotePort)
+ ctx["localAddress"] = ipinfo.localAddress
+ ctx["localPort"] = str(ipinfo.localPort)
+ ctx["remoteAddress"] = ipinfo.remoteAddress
+ ctx["remotePort"] = str(ipinfo.remotePort)
- if isinstance(info, Ice.WSConnectionInfo) or isinstance(info, Ice.WSSConnectionInfo):
+ if isinstance(info, Ice.WSConnectionInfo):
for key, value in info.headers.items():
ctx["ws." + key] = value
diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp
index 1b95f3a629b..6b4b57efdc7 100644
--- a/ruby/src/IceRuby/Connection.cpp
+++ b/ruby/src/IceRuby/Connection.cpp
@@ -25,7 +25,6 @@ static VALUE _tcpConnectionInfoClass;
static VALUE _udpConnectionInfoClass;
static VALUE _wsConnectionInfoClass;
static VALUE _sslConnectionInfoClass;
-static VALUE _wssConnectionInfoClass;
// **********************************************************************
// Connection
@@ -293,17 +292,17 @@ IceRuby_ConnectionInfo_free(Ice::ConnectionInfoPtr* p)
VALUE
IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p)
{
+ if(!p)
+ {
+ return Qnil;
+ }
+
VALUE info;
if(Ice::WSConnectionInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_wsConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
Ice::WSConnectionInfoPtr ws = Ice::WSConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(ws->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ws->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ws->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ws->remotePort));
-
volatile VALUE result = callRuby(rb_hash_new);
for(Ice::HeaderDict::const_iterator q = ws->headers.begin(); q != ws->headers.end(); ++q)
{
@@ -318,54 +317,24 @@ IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p)
info = Data_Wrap_Struct(_tcpConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
Ice::TCPConnectionInfoPtr tcp = Ice::TCPConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(tcp->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(tcp->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(tcp->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(tcp->remotePort));
+ rb_ivar_set(info, rb_intern("@rcvSize"), INT2FIX(tcp->rcvSize));
+ rb_ivar_set(info, rb_intern("@sndSize"), INT2FIX(tcp->sndSize));
}
else if(Ice::UDPConnectionInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_udpConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
Ice::UDPConnectionInfoPtr udp = Ice::UDPConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(udp->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(udp->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(udp->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(udp->remotePort));
rb_ivar_set(info, rb_intern("@mcastAddress"), createString(udp->mcastAddress));
rb_ivar_set(info, rb_intern("@mcastPort"), INT2FIX(udp->mcastPort));
- }
- else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p))
- {
- info = Data_Wrap_Struct(_wssConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
-
- IceSSL::WSSConnectionInfoPtr wss = IceSSL::WSSConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(wss->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(wss->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(wss->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(wss->remotePort));
- rb_ivar_set(info, rb_intern("@cipher"), createString(wss->cipher));
- rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(wss->certs));
- rb_ivar_set(info, rb_intern("@verified"), wss->verified ? Qtrue : Qfalse);
-
- volatile VALUE result = callRuby(rb_hash_new);
- for(Ice::HeaderDict::const_iterator q = wss->headers.begin(); q != wss->headers.end(); ++q)
- {
- volatile VALUE key = createString(q->first);
- volatile VALUE value = createString(q->second);
- callRuby(rb_hash_aset, result, key, value);
- }
- rb_ivar_set(info, rb_intern("@headers"), result);
+ rb_ivar_set(info, rb_intern("@rcvSize"), INT2FIX(udp->rcvSize));
+ rb_ivar_set(info, rb_intern("@sndSize"), INT2FIX(udp->sndSize));
}
else if(IceSSL::ConnectionInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_sslConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
IceSSL::ConnectionInfoPtr ssl = IceSSL::ConnectionInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@localAddress"), createString(ssl->localAddress));
- rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ssl->localPort));
- rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ssl->remoteAddress));
- rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ssl->remotePort));
rb_ivar_set(info, rb_intern("@cipher"), createString(ssl->cipher));
rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(ssl->certs));
rb_ivar_set(info, rb_intern("@verified"), ssl->verified ? Qtrue : Qfalse);
@@ -374,20 +343,24 @@ IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p)
{
info = Data_Wrap_Struct(_ipConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
+ }
+ else
+ {
+ info = Data_Wrap_Struct(_connectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
+ }
+
+ if(Ice::IPConnectionInfoPtr::dynamicCast(p))
+ {
Ice::IPConnectionInfoPtr ip = Ice::IPConnectionInfoPtr::dynamicCast(p);
rb_ivar_set(info, rb_intern("@localAddress"), createString(ip->localAddress));
rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ip->localPort));
rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ip->remoteAddress));
rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ip->remotePort));
}
- else
- {
- info = Data_Wrap_Struct(_connectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p));
- }
+
+ rb_ivar_set(info, rb_intern("@underlying"), createConnectionInfo(p->underlying));
rb_ivar_set(info, rb_intern("@incoming"), p->incoming ? Qtrue : Qfalse);
rb_ivar_set(info, rb_intern("@adapterName"), createString(p->adapterName));
- rb_ivar_set(info, rb_intern("@rcvSize"), INT2FIX(p->rcvSize));
- rb_ivar_set(info, rb_intern("@sndSize"), INT2FIX(p->sndSize));
return info;
}
@@ -462,7 +435,7 @@ IceRuby::initConnection(VALUE iceModule)
//
// WSConnectionInfo
//
- _wsConnectionInfoClass = rb_define_class_under(iceModule, "WSConnectionInfo", _ipConnectionInfoClass);
+ _wsConnectionInfoClass = rb_define_class_under(iceModule, "WSConnectionInfo", _connectionInfoClass);
//
// Instance members.
@@ -472,7 +445,7 @@ IceRuby::initConnection(VALUE iceModule)
//
// SSLConnectionInfo
//
- _sslConnectionInfoClass = rb_define_class_under(iceModule, "SSLConnectionInfo", _ipConnectionInfoClass);
+ _sslConnectionInfoClass = rb_define_class_under(iceModule, "SSLConnectionInfo", _connectionInfoClass);
//
// Instance members.
@@ -480,14 +453,4 @@ IceRuby::initConnection(VALUE iceModule)
rb_define_attr(_wsConnectionInfoClass, "cipher", 1, 0);
rb_define_attr(_wsConnectionInfoClass, "certs", 1, 0);
rb_define_attr(_wsConnectionInfoClass, "verified", 1, 0);
-
- //
- // WSSConnectionInfo
- //
- _wssConnectionInfoClass = rb_define_class_under(iceModule, "WSSConnectionInfo", _sslConnectionInfoClass);
-
- //
- // Instance members.
- //
- rb_define_attr(_wssConnectionInfoClass, "headers", 1, 0);
}
diff --git a/ruby/src/IceRuby/Endpoint.cpp b/ruby/src/IceRuby/Endpoint.cpp
index 0b6db76aa83..46ced54ea11 100644
--- a/ruby/src/IceRuby/Endpoint.cpp
+++ b/ruby/src/IceRuby/Endpoint.cpp
@@ -24,7 +24,6 @@ static VALUE _udpEndpointInfoClass;
static VALUE _wsEndpointInfoClass;
static VALUE _opaqueEndpointInfoClass;
static VALUE _sslEndpointInfoClass;
-static VALUE _wssEndpointInfoClass;
// **********************************************************************
// Endpoint
@@ -132,34 +131,28 @@ IceRuby_EndpointInfo_free(Ice::EndpointPtr* p)
VALUE
IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p)
{
+ if(!p)
+ {
+ return Qnil;
+ }
+
VALUE info;
if(Ice::WSEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_wsEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
Ice::WSEndpointInfoPtr ws = Ice::WSEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(ws->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(ws->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ws->sourceAddress));
rb_ivar_set(info, rb_intern("@resource"), createString(ws->resource));
}
else if(Ice::TCPEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_tcpEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
-
- Ice::TCPEndpointInfoPtr tcp = Ice::TCPEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(tcp->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(tcp->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(tcp->sourceAddress));
}
else if(Ice::UDPEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_udpEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
Ice::UDPEndpointInfoPtr udp = Ice::UDPEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(udp->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(udp->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(udp->sourceAddress));
rb_ivar_set(info, rb_intern("@mcastInterface"), createString(udp->mcastInterface));
rb_ivar_set(info, rb_intern("@mcastTtl"), INT2FIX(udp->mcastTtl));
}
@@ -173,39 +166,28 @@ IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p)
rb_ivar_set(info, rb_intern("@rawBytes"), v);
rb_ivar_set(info, rb_intern("@rawEncoding"), createEncodingVersion(opaque->rawEncoding));
}
- else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p))
- {
- info = Data_Wrap_Struct(_wssEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
-
- IceSSL::WSSEndpointInfoPtr wss = IceSSL::WSSEndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(wss->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(wss->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(wss->sourceAddress));
- rb_ivar_set(info, rb_intern("@resource"), createString(wss->resource));
- }
else if(IceSSL::EndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_sslEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
-
- IceSSL::EndpointInfoPtr ssl = IceSSL::EndpointInfoPtr::dynamicCast(p);
- rb_ivar_set(info, rb_intern("@host"), createString(ssl->host));
- rb_ivar_set(info, rb_intern("@port"), INT2FIX(ssl->port));
- rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ssl->sourceAddress));
}
else if(Ice::IPEndpointInfoPtr::dynamicCast(p))
{
info = Data_Wrap_Struct(_ipEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
+ }
+ else
+ {
+ info = Data_Wrap_Struct(_endpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
+ }
+ if(Ice::IPEndpointInfoPtr::dynamicCast(p))
+ {
Ice::IPEndpointInfoPtr ip = Ice::IPEndpointInfoPtr::dynamicCast(p);
rb_ivar_set(info, rb_intern("@host"), createString(ip->host));
rb_ivar_set(info, rb_intern("@port"), INT2FIX(ip->port));
rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ip->sourceAddress));
}
- else
- {
- info = Data_Wrap_Struct(_endpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p));
- }
+ rb_ivar_set(info, rb_intern("@underlying"), createEndpointInfo(p->underlying));
rb_ivar_set(info, rb_intern("@timeout"), INT2FIX(p->timeout));
rb_ivar_set(info, rb_intern("@compress"), p->compress ? Qtrue : Qfalse);
return info;
@@ -329,7 +311,7 @@ IceRuby::initEndpoint(VALUE iceModule)
//
// WSEndpointInfo
//
- _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _tcpEndpointInfoClass);
+ _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _endpointInfoClass);
//
// Instance members.
@@ -350,17 +332,7 @@ IceRuby::initEndpoint(VALUE iceModule)
//
// SSLEndpointInfo
//
- _sslEndpointInfoClass = rb_define_class_under(iceModule, "SSLEndpointInfo", _ipEndpointInfoClass);
-
- //
- // WSSEndpointInfo
- //
- _wssEndpointInfoClass = rb_define_class_under(iceModule, "WSSEndpointInfo", _sslEndpointInfoClass);
-
- //
- // Instance members.
- //
- rb_define_attr(_wssEndpointInfoClass, "resource", 1, 0);
+ _sslEndpointInfoClass = rb_define_class_under(iceModule, "SSLEndpointInfo", _endpointInfoClass);
}
bool
diff --git a/ruby/test/Ice/info/AllTests.rb b/ruby/test/Ice/info/AllTests.rb
index c3607ef1190..e86497ade99 100644
--- a/ruby/test/Ice/info/AllTests.rb
+++ b/ruby/test/Ice/info/AllTests.rb
@@ -7,6 +7,24 @@
#
# **********************************************************************
+def getTCPEndpointInfo(info)
+ while info
+ if info.is_a?(Ice::TCPEndpointInfo)
+ return info
+ end
+ info = info.underlying
+ end
+end
+
+def getTCPConnectionInfo(info)
+ while info
+ if info.is_a?(Ice::TCPConnectionInfo)
+ return info
+ end
+ info = info.underlying
+ end
+end
+
def allTests(communicator)
print "testing proxy endpoint information..."
STDOUT.flush
@@ -16,23 +34,23 @@ def allTests(communicator)
"opaque -e 1.8 -t 100 -v ABCD")
endps = p1.ice_getEndpoints()
-
- ipEndpoint = endps[0].getInfo()
- test(ipEndpoint.is_a?(Ice::IPEndpointInfo));
- test(ipEndpoint.host == "tcphost")
- test(ipEndpoint.port == 10000)
- test(ipEndpoint.sourceAddress == "10.10.10.10")
- test(ipEndpoint.timeout == 1200)
- test(ipEndpoint.compress)
- test(!ipEndpoint.datagram())
- test((ipEndpoint.type() == Ice::TCPEndpointType && !ipEndpoint.secure()) ||
- (ipEndpoint.type() == Ice::SSLEndpointType && ipEndpoint.secure()) ||
- (ipEndpoint.type() == Ice::WSEndpointType && !ipEndpoint.secure()) ||
- (ipEndpoint.type() == Ice::WSSEndpointType && ipEndpoint.secure()))
- test((ipEndpoint.type() == Ice::TCPEndpointType && ipEndpoint.is_a?(Ice::TCPEndpointInfo)) ||
- (ipEndpoint.type() == Ice::SSLEndpointType && ipEndpoint.is_a?(Ice::SSLEndpointInfo)) ||
- (ipEndpoint.type() == Ice::WSEndpointType && ipEndpoint.is_a?(Ice::WSEndpointInfo)) ||
- (ipEndpoint.type() == Ice::WSSEndpointType && ipEndpoint.is_a?(Ice::WSSEndpointInfo)))
+ endpoint = endps[0].getInfo()
+ tcpEndpoint = getTCPEndpointInfo(endpoint)
+ test(tcpEndpoint.is_a?(Ice::TCPEndpointInfo));
+ test(tcpEndpoint.host == "tcphost")
+ test(tcpEndpoint.port == 10000)
+ test(tcpEndpoint.sourceAddress == "10.10.10.10")
+ test(tcpEndpoint.timeout == 1200)
+ test(tcpEndpoint.compress)
+ test(!tcpEndpoint.datagram())
+ test((tcpEndpoint.type() == Ice::TCPEndpointType && !tcpEndpoint.secure()) ||
+ (tcpEndpoint.type() == Ice::SSLEndpointType && tcpEndpoint.secure()) ||
+ (tcpEndpoint.type() == Ice::WSEndpointType && !tcpEndpoint.secure()) ||
+ (tcpEndpoint.type() == Ice::WSSEndpointType && tcpEndpoint.secure()))
+ test((tcpEndpoint.type() == Ice::TCPEndpointType && endpoint.is_a?(Ice::TCPEndpointInfo)) ||
+ (tcpEndpoint.type() == Ice::SSLEndpointType && endpoint.is_a?(Ice::SSLEndpointInfo)) ||
+ (tcpEndpoint.type() == Ice::WSEndpointType && endpoint.is_a?(Ice::WSEndpointInfo)) ||
+ (tcpEndpoint.type() == Ice::WSSEndpointType && endpoint.is_a?(Ice::WSEndpointInfo)))
udpEndpoint = endps[1].getInfo()
test(udpEndpoint.is_a?(Ice::UDPEndpointInfo));
@@ -60,13 +78,13 @@ def allTests(communicator)
print "test connection endpoint information..."
STDOUT.flush
- ipinfo = base.ice_getConnection().getEndpoint().getInfo()
- test(ipinfo.port == 12010)
- test(!ipinfo.compress)
- test(ipinfo.host == defaultHost)
+ tcpinfo = getTCPEndpointInfo(base.ice_getConnection().getEndpoint().getInfo())
+ test(tcpinfo.port == 12010)
+ test(!tcpinfo.compress)
+ test(tcpinfo.host == defaultHost)
ctx = testIntf.getEndpointInfoAsContext()
- test(ctx["host"] == ipinfo.host)
+ test(ctx["host"] == tcpinfo.host)
test(ctx["compress"] == "false")
port = Integer(ctx["port"])
test(port > 0)
@@ -84,27 +102,28 @@ def allTests(communicator)
connection.setBufferSize(1024, 2048)
info = connection.getInfo()
+ tcpinfo = getTCPConnectionInfo(info)
+
test(!info.incoming)
test(info.adapterName.length == 0)
- test(info.remotePort == 12010)
+ test(tcpinfo.remotePort == 12010)
if defaultHost == "127.0.0.1"
- test(info.remoteAddress == defaultHost)
- test(info.localAddress == defaultHost)
+ test(tcpinfo.remoteAddress == defaultHost)
+ test(tcpinfo.localAddress == defaultHost)
end
- test(info.rcvSize >= 1024)
- test(info.sndSize >= 2048)
+ test(tcpinfo.rcvSize >= 1024)
+ test(tcpinfo.sndSize >= 2048)
ctx = testIntf.getConnectionInfoAsContext()
test(ctx["incoming"] == "true")
test(ctx["adapterName"] == "TestAdapter")
- test(ctx["remoteAddress"] == info.localAddress)
- test(ctx["localAddress"] == info.remoteAddress)
- test(ctx["remotePort"] == info.localPort.to_s())
- test(ctx["localPort"] == info.remotePort.to_s())
+ test(ctx["remoteAddress"] == tcpinfo.localAddress)
+ test(ctx["localAddress"] == tcpinfo.remoteAddress)
+ test(ctx["remotePort"] == tcpinfo.localPort.to_s())
+ test(ctx["localPort"] == tcpinfo.remotePort.to_s())
if base.ice_getConnection().type() == "ws" || base.ice_getConnection().type() == "wss"
- test((base.ice_getConnection().type() == "ws" && info.is_a?(Ice::WSConnectionInfo)) ||
- (base.ice_getConnection().type() == "wss" && info.is_a?(Ice::WSSConnectionInfo)))
+ test(info.is_a?(Ice::WSConnectionInfo))
test(info.headers["Upgrade"] == "websocket")
test(info.headers["Connection"] == "Upgrade")
diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice
index a81737a1e95..666ce118462 100644
--- a/slice/Ice/Connection.ice
+++ b/slice/Ice/Connection.ice
@@ -27,6 +27,14 @@ local class ConnectionInfo
{
/**
*
+ * The information of the underyling transport or null if there's
+ * no underlying transport.
+ *
+ **/
+ ConnectionInfo underlying;
+
+ /**
+ *
* Whether or not the connection is an incoming or outgoing
* connection.
*
@@ -46,20 +54,6 @@ local class ConnectionInfo
*
**/
string connectionId;
-
- /**
- *
- * The connection buffer receive size.
- *
- **/
- int rcvSize;
-
- /**
- *
- * The connection buffer send size.
- *
- **/
- int sndSize;
};
local interface Connection;
@@ -344,6 +338,19 @@ local class IPConnectionInfo extends ConnectionInfo
**/
local class TCPConnectionInfo extends IPConnectionInfo
{
+ /**
+ *
+ * The connection buffer receive size.
+ *
+ **/
+ int rcvSize = 0;
+
+ /**
+ *
+ * The connection buffer send size.
+ *
+ **/
+ int sndSize = 0;
};
/**
@@ -353,11 +360,33 @@ local class TCPConnectionInfo extends IPConnectionInfo
**/
local class UDPConnectionInfo extends IPConnectionInfo
{
- /** The multicast address. */
+ /**
+ *
+ * The multicast address.
+ *
+ **/
string mcastAddress;
- /** The multicast port. */
+ /**
+ *
+ * The multicast port.
+ *
+ **/
int mcastPort = -1;
+
+ /**
+ *
+ * The connection buffer receive size.
+ *
+ **/
+ int rcvSize = 0;
+
+ /**
+ *
+ * The connection buffer send size.
+ *
+ **/
+ int sndSize = 0;
};
dictionary<string, string> HeaderDict;
@@ -367,7 +396,7 @@ dictionary<string, string> HeaderDict;
* Provides access to the connection details of a WebSocket connection
*
**/
-local class WSConnectionInfo extends TCPConnectionInfo
+local class WSConnectionInfo extends ConnectionInfo
{
/** The headers from the HTTP upgrade request. */
HeaderDict headers;
diff --git a/slice/Ice/Endpoint.ice b/slice/Ice/Endpoint.ice
index f7a6ff708e7..4775e152a27 100644
--- a/slice/Ice/Endpoint.ice
+++ b/slice/Ice/Endpoint.ice
@@ -56,17 +56,31 @@ const short WSSEndpointType = 5;
/**
*
+ * Uniquely identifies Bluetooth endpoints.
+ *
+ **/
+const short BTEndpointType = 6;
+
+/**
+ *
+ * Uniquely identifies SSL Bluetooth endpoints.
+ *
+ **/
+const short BTSEndpointType = 7;
+
+/**
+ *
* Uniquely identifies iAP-based endpoints.
*
**/
-const short iAPEndpointType = 6;
+const short iAPEndpointType = 8;
/**
*
* Uniquely identifies SSL iAP-based endpoints.
*
**/
-const short iAPSEndpointType = 7;
+const short iAPSEndpointType = 9;
/**
*
@@ -77,6 +91,14 @@ local class EndpointInfo
{
/**
*
+ * The information of the underyling endpoint of null if there's
+ * no underlying endpoint.
+ *
+ **/
+ EndpointInfo underlying;
+
+ /**
+ *
* The timeout for the endpoint in milliseconds. 0 means
* non-blocking, -1 means no timeout.
*
@@ -211,7 +233,7 @@ local class UDPEndpointInfo extends IPEndpointInfo
* Provides access to a WebSocket endpoint information.
*
**/
-local class WSEndpointInfo extends TCPEndpointInfo
+local class WSEndpointInfo extends EndpointInfo
{
/**
*
diff --git a/slice/IceBT/ConnectionInfo.ice b/slice/IceBT/ConnectionInfo.ice
index 996fa7ecf41..db128dfa868 100644
--- a/slice/IceBT/ConnectionInfo.ice
+++ b/slice/IceBT/ConnectionInfo.ice
@@ -38,6 +38,12 @@ local class ConnectionInfo extends Ice::ConnectionInfo
/** The UUID of the service being offered (in a server) or targeted (in a client). */
string uuid = "";
+
+ /** The connection buffer receive size. **/
+ int rcvSize = 0;
+
+ /** The connection buffer send size. **/
+ int sndSize = 0;
};
};
diff --git a/slice/IceBT/EndpointInfo.ice b/slice/IceBT/EndpointInfo.ice
index 383780f623b..c7018aacec6 100644
--- a/slice/IceBT/EndpointInfo.ice
+++ b/slice/IceBT/EndpointInfo.ice
@@ -24,15 +24,6 @@ module IceBT
/**
*
- * Uniquely identifies Bluetooth endpoints.
- *
- **/
-#ifndef __SLICE2OBJC__
-const short EndpointType = 6;
-#endif
-
-/**
- *
* Provides access to Bluetooth endpoint information.
*
**/
diff --git a/slice/IceIAP/ConnectionInfo.ice b/slice/IceIAP/ConnectionInfo.ice
new file mode 100644
index 00000000000..b4dfdddd392
--- /dev/null
+++ b/slice/IceIAP/ConnectionInfo.ice
@@ -0,0 +1,71 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#pragma once
+
+[["cpp:header-ext:h", "objc:header-dir:objc", "js:ice-build"]]
+
+#include <Ice/Connection.ice>
+
+["objc:prefix:ICEIAP"]
+module IceIAP
+{
+
+/**
+ *
+ * Provides access to the connection details of an IAP connection
+ *
+ **/
+local class ConnectionInfo extends Ice::ConnectionInfo
+{
+ /**
+ *
+ * The accessory name.
+ *
+ **/
+ string name;
+
+ /**
+ *
+ * The accessory manufacturer.
+ *
+ **/
+ string manufacturer;
+
+ /**
+ *
+ * The accessory model number.
+ *
+ **/
+ string modelNumber;
+
+ /**
+ *
+ * The accessory firmare revision.
+ *
+ **/
+ string firmwareRevision;
+
+ /**
+ *
+ * The accessory hardware revision.
+ *
+ **/
+ string hardwareRevision;
+
+ /**
+ *
+ * The protocol used by the accessory.
+ *
+ **/
+ string protocol;
+};
+
+};
+
diff --git a/slice/IceIAP/EndpointInfo.ice b/slice/IceIAP/EndpointInfo.ice
new file mode 100644
index 00000000000..69404a8f00e
--- /dev/null
+++ b/slice/IceIAP/EndpointInfo.ice
@@ -0,0 +1,65 @@
+// **********************************************************************
+//
+// Copyright (c) 2016-2016 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#pragma once
+
+[["cpp:header-ext:h", "objc:header-dir:objc", "js:ice-build"]]
+
+#include <Ice/Endpoint.ice>
+
+/**
+ *
+ * IceIAP provides a secure transport for Ice.
+ *
+ **/
+["objc:prefix:ICEIAP"]
+module IceIAP
+{
+
+/**
+ *
+ * Provides access to an IAP endpoint information.
+ *
+ **/
+local class EndpointInfo extends Ice::EndpointInfo
+{
+ /**
+ *
+ * The accessory manufacturer or empty to not match against
+ * a manufacturer.
+ *
+ **/
+ string manufacturer;
+
+ /**
+ *
+ * The accessory model number or empty to not match against
+ * a model number.
+ *
+ **/
+ string modelNumber;
+
+ /**
+ *
+ * The accessory name or empty to not match against
+ * the accessory name.
+ *
+ **/
+ string name;
+
+ /**
+ *
+ * The protocol supported by the accessory.
+ *
+ **/
+ string protocol;
+};
+
+};
+
diff --git a/slice/IceSSL/ConnectionInfo.ice b/slice/IceSSL/ConnectionInfo.ice
index cf3737d2817..b9e09e2ff32 100644
--- a/slice/IceSSL/ConnectionInfo.ice
+++ b/slice/IceSSL/ConnectionInfo.ice
@@ -22,7 +22,7 @@ module IceSSL
* Provides access to the connection details of an SSL connection
*
**/
-local class ConnectionInfo extends Ice::IPConnectionInfo
+local class ConnectionInfo extends Ice::ConnectionInfo
{
/** The negotiated cipher suite. */
string cipher;
@@ -34,16 +34,5 @@ local class ConnectionInfo extends Ice::IPConnectionInfo
bool verified;
};
-/**
- *
- * Provides access to the connection details of a secure WebSocket connection
- *
- **/
-local class WSSConnectionInfo extends ConnectionInfo
-{
- /** The headers from the HTTP upgrade request. */
- Ice::HeaderDict headers;
-};
-
};
diff --git a/slice/IceSSL/EndpointInfo.ice b/slice/IceSSL/EndpointInfo.ice
index 4bcf6bd4fdf..a93bc334d8b 100644
--- a/slice/IceSSL/EndpointInfo.ice
+++ b/slice/IceSSL/EndpointInfo.ice
@@ -24,35 +24,11 @@ module IceSSL
/**
*
- * Uniquely identifies SSL endpoints.
- *
- **/
-#ifndef __SLICE2OBJC__ // In Objective-C, Ice::SSLEndpointType is already mapped to ICESSLEndpointType
-const short EndpointType = Ice::SSLEndpointType;
-#endif
-
-/**
- *
* Provides access to an SSL endpoint information.
*
**/
-local class EndpointInfo extends Ice::IPEndpointInfo
-{
-};
-
-/**
- *
- * Provides access to a secure WebSocket endpoint information.
- *
- **/
-local class WSSEndpointInfo extends EndpointInfo
+local class EndpointInfo extends Ice::EndpointInfo
{
- /**
- *
- * The URI configured with the endpoint.
- *
- **/
- string resource;
};
};