summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
authorDaniel Lowrey <rdlowrey@php.net>2015-02-28 15:32:15 -0500
committerDaniel Lowrey <rdlowrey@php.net>2015-02-28 17:41:29 -0500
commit13acb7ec653c543c56437ed417c3889fbf54f608 (patch)
treece4f370ed06d601b6964ac3ba6aeb73b530da2fb /ext/standard
parent3ff36c265fce0ec5375e1917764db4fca88eb1ae (diff)
downloadphp-git-13acb7ec653c543c56437ed417c3889fbf54f608.tar.gz
Add stream_socket_crypto_info() function
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/basic_functions.c6
-rw-r--r--ext/standard/file.c5
-rw-r--r--ext/standard/streamsfuncs.c39
-rw-r--r--ext/standard/streamsfuncs.h1
4 files changed, 51 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 26f72098bf..0249d617df 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2103,6 +2103,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_stream_socket_enable_crypto, 0, 0, 2)
ZEND_ARG_INFO(0, sessionstream)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO(arginfo_stream_socket_crypto_info, 0)
+ ZEND_ARG_INFO(0, stream)
+ ZEND_ARG_INFO(0, infotype)
+ZEND_END_ARG_INFO()
+
#ifdef HAVE_SHUTDOWN
ZEND_BEGIN_ARG_INFO(arginfo_stream_socket_shutdown, 0)
ZEND_ARG_INFO(0, stream)
@@ -3086,6 +3091,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */
PHP_FE(stream_socket_recvfrom, arginfo_stream_socket_recvfrom)
PHP_FE(stream_socket_sendto, arginfo_stream_socket_sendto)
PHP_FE(stream_socket_enable_crypto, arginfo_stream_socket_enable_crypto)
+ PHP_FE(stream_socket_crypto_info, arginfo_stream_socket_crypto_info)
#ifdef HAVE_SHUTDOWN
PHP_FE(stream_socket_shutdown, arginfo_stream_socket_shutdown)
#endif
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 3599313a71..b001fdd79b 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -231,6 +231,11 @@ PHP_MINIT_FUNCTION(file)
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_1_SERVER", STREAM_CRYPTO_METHOD_TLSv1_1_SERVER, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_CRYPTO_METHOD_TLSv1_2_SERVER", STREAM_CRYPTO_METHOD_TLSv1_2_SERVER, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("STREAM_CRYPTO_INFO_PROTOCOL", STREAM_CRYPTO_INFO_PROTOCOL, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("STREAM_CRYPTO_INFO_CIPHER_NAME", STREAM_CRYPTO_INFO_CIPHER_NAME, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("STREAM_CRYPTO_INFO_CIPHER_BITS", STREAM_CRYPTO_INFO_CIPHER_BITS, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("STREAM_CRYPTO_INFO_CIPHER_VERSION", STREAM_CRYPTO_INFO_CIPHER_VERSION, CONST_CS|CONST_PERSISTENT);
+
REGISTER_LONG_CONSTANT("STREAM_SHUT_RD", STREAM_SHUT_RD, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SHUT_WR", STREAM_SHUT_WR, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STREAM_SHUT_RDWR", STREAM_SHUT_RDWR, CONST_CS|CONST_PERSISTENT);
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 46c2aaa9a1..a344ed69db 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -1485,6 +1485,45 @@ PHP_FUNCTION(stream_socket_enable_crypto)
}
/* }}} */
+/* {{{ proto int stream_socket_crypto_info(resource stream [, int infotype])
+ Retrieve information about the stream's crypto session */
+PHP_FUNCTION(stream_socket_crypto_info)
+{
+ zval *zstream = NULL;
+ php_stream *stream = NULL;
+ zend_long infotype = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zstream, &infotype) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_stream_from_zval(stream, zstream);
+
+ if (infotype == 0) {
+ infotype = STREAM_CRYPTO_INFO_ALL;
+ } else {
+ switch (infotype) {
+ case STREAM_CRYPTO_INFO_CIPHER_NAME:
+ case STREAM_CRYPTO_INFO_CIPHER_BITS:
+ case STREAM_CRYPTO_INFO_CIPHER_VERSION:
+ case STREAM_CRYPTO_INFO_CIPHER:
+ case STREAM_CRYPTO_INFO_PROTOCOL:
+ case STREAM_CRYPTO_INFO_ALL:
+ break;
+ default:
+ php_error_docref(NULL, E_WARNING, "unknown crypto info type");
+ RETURN_FALSE;
+ }
+ }
+
+ if (php_stream_xport_crypto_info(stream, infotype, return_value) != PHP_STREAM_OPTION_RETURN_OK) {
+ RETURN_FALSE;
+ }
+
+ /* return_value populated by php_stream_xport_crypto_info() upon success */
+}
+/* }}} */
+
/* {{{ proto string stream_resolve_include_path(string filename)
Determine what file will be opened by calls to fopen() with a relative path */
PHP_FUNCTION(stream_resolve_include_path)
diff --git a/ext/standard/streamsfuncs.h b/ext/standard/streamsfuncs.h
index 37c6594dd2..07fe5fa572 100644
--- a/ext/standard/streamsfuncs.h
+++ b/ext/standard/streamsfuncs.h
@@ -57,6 +57,7 @@ PHP_FUNCTION(stream_filter_prepend);
PHP_FUNCTION(stream_filter_append);
PHP_FUNCTION(stream_filter_remove);
PHP_FUNCTION(stream_socket_enable_crypto);
+PHP_FUNCTION(stream_socket_crypto_info);
PHP_FUNCTION(stream_socket_shutdown);
PHP_FUNCTION(stream_resolve_include_path);
PHP_FUNCTION(stream_is_local);