summaryrefslogtreecommitdiff
path: root/main/streams/php_stream_transport.h
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2003-02-27 17:43:38 +0000
committerWez Furlong <wez@php.net>2003-02-27 17:43:38 +0000
commitfd61f69077f6156ca71dde60ecfd9ed9765a02db (patch)
tree7285ad393cdb5a85107a3329d1ab2bcafe89f051 /main/streams/php_stream_transport.h
parent560e33968de93250377606782949f5004affca83 (diff)
downloadphp-git-fd61f69077f6156ca71dde60ecfd9ed9765a02db.tar.gz
Another big commit (tm).
Main Changes: - Implement a socket transport layer for use by all code that needs to open some kind of "special" socket for network or IPC. - Extensions can register (and override) transports. - Implement ftruncate() on streams via the ioctl-alike option interface. - Implement mmap() on streams via the ioctl-alike option interface. - Implement generic crypto API via the ioctl-alike option interface. (currently only supports OpenSSL, but could support other SSL toolkits, and other crypto transport protocols). Impact: - tcp sockets can be overloaded by the openssl capable sockets at runtime, removing the link-time requirement for ssl:// and https:// sockets and streams. - checking stream types using PHP_STREAM_IS_SOCKET is deprecated, since there are now a range of possible socket-type streams. Working towards: - socket servers using the new transport layer - mmap support under win32 - Cleaner code. # I will be updating the win32 build to add the new files shortly # after this commit.
Diffstat (limited to 'main/streams/php_stream_transport.h')
-rw-r--r--main/streams/php_stream_transport.h153
1 files changed, 153 insertions, 0 deletions
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
new file mode 100644
index 0000000000..89642b5652
--- /dev/null
+++ b/main/streams/php_stream_transport.h
@@ -0,0 +1,153 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2003 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Wez Furlong <wez@thebrainroom.com> |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+typedef php_stream *(php_stream_transport_factory_func)(const char *proto, long protolen,
+ char *resourcename, long resourcenamelen,
+ const char *persistent_id, int options, int flags,
+ struct timeval *timeout,
+ php_stream_context *context STREAMS_DC TSRMLS_DC);
+typedef php_stream_transport_factory_func *php_stream_transport_factory;
+
+PHPAPI int php_stream_xport_register(char *protocol, php_stream_transport_factory factory TSRMLS_DC);
+PHPAPI int php_stream_xport_unregister(char *protocol TSRMLS_DC);
+
+#define STREAM_XPORT_CLIENT 0
+#define STREAM_XPORT_SERVER 1
+
+#define STREAM_XPORT_CONNECT 2
+#define STREAM_XPORT_BIND 4
+#define STREAM_XPORT_LISTEN 8
+#define STREAM_XPORT_CONNECT_ASYNC 16
+
+/* Open a client or server socket connection */
+PHPAPI php_stream *_php_stream_xport_create(const char *name, long namelen, int options,
+ int flags, const char *persistent_id,
+ struct timeval *timeout,
+ php_stream_context *context,
+ char **error_string,
+ int *error_code
+ STREAMS_DC TSRMLS_DC);
+
+#define php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode) \
+ _php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode STREAMS_CC TSRMLS_CC)
+
+/* Bind the stream to a local address */
+PHPAPI int php_stream_xport_bind(php_stream *stream,
+ const char *name, long namelen,
+ char **error_text
+ TSRMLS_DC);
+
+/* Connect to a remote address */
+PHPAPI int php_stream_xport_connect(php_stream *stream,
+ const char *name, long namelen,
+ int asynchronous,
+ struct timeval *timeout,
+ char **error_text,
+ int *error_code
+ TSRMLS_DC);
+
+/* Prepare to listen */
+PHPAPI int php_stream_xport_listen(php_stream *stream,
+ int backlog,
+ char **error_text
+ TSRMLS_DC);
+
+/* Get the next client and their address as a string, or the underlying address
+ * structure. You must efree either of these if you request them */
+PHPAPI int php_stream_xport_accept(php_stream *stream, php_stream **client,
+ char **textaddr, long *textaddrlen,
+ void **addr, size_t *addrlen,
+ struct timeval *timeout,
+ char **error_text
+ TSRMLS_DC);
+
+/* Structure definition for the set_option interface that the above functions wrap */
+
+typedef struct _php_stream_xport_param {
+ enum {
+ STREAM_XPORT_OP_BIND, STREAM_XPORT_OP_CONNECT,
+ STREAM_XPORT_OP_LISTEN, STREAM_XPORT_OP_ACCEPT,
+ STREAM_XPORT_OP_CONNECT_ASYNC
+ } op;
+ int want_addr:1;
+ int want_textaddr:1;
+ int want_errortext:1;
+
+ struct {
+ char *name;
+ long namelen;
+ int backlog;
+ struct timeval *timeout;
+ } inputs;
+ struct {
+ php_stream *client;
+ int returncode;
+ void *addr;
+ size_t addrlen;
+ char *textaddr;
+ long textaddrlen;
+
+ char *error_text;
+ int error_code;
+ } outputs;
+} php_stream_xport_param;
+
+
+/* These functions provide crypto support on the underlying transport */
+typedef enum {
+ STREAM_CRYPTO_METHOD_SSLv2_CLIENT,
+ STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
+ STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
+ STREAM_CRYPTO_METHOD_TLS_CLIENT,
+ STREAM_CRYPTO_METHOD_SSLv2_SERVER,
+ STREAM_CRYPTO_METHOD_SSLv3_SERVER,
+ STREAM_CRYPTO_METHOD_SSLv23_SERVER,
+ STREAM_CRYPTO_METHOD_TLS_SERVER
+} php_stream_xport_crypt_method_t;
+
+PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream TSRMLS_DC);
+PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate TSRMLS_DC);
+
+typedef struct _php_stream_xport_crypto_param {
+ enum {
+ STREAM_XPORT_CRYPTO_OP_SETUP,
+ STREAM_XPORT_CRYPTO_OP_ENABLE
+ } op;
+ struct {
+ int activate;
+ php_stream_xport_crypt_method_t method;
+ php_stream *session;
+ } inputs;
+ struct {
+ int returncode;
+ } outputs;
+} php_stream_xport_crypto_param;
+
+PHPAPI HashTable *php_stream_xport_get_hash(void);
+PHPAPI php_stream_transport_factory_func php_stream_generic_socket_factory;
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */