diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-06-27 17:54:30 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-06-27 17:54:30 +0200 |
commit | c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7 (patch) | |
tree | 5cb64dfe155e5d2349efb6c7dc4b0f5b5284d44a /php/src | |
parent | Fix Windows php build to restore nuget packages (diff) | |
download | ice-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.
Diffstat (limited to 'php/src')
-rw-r--r-- | php/src/php5/Connection.cpp | 63 | ||||
-rw-r--r-- | php/src/php5/Endpoint.cpp | 43 | ||||
-rw-r--r-- | php/src/php7/Connection.cpp | 60 | ||||
-rw-r--r-- | php/src/php7/Endpoint.cpp | 40 |
4 files changed, 86 insertions, 120 deletions
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)); |