php-src/main/streams/php_stream_transport.h

154 lines
5.0 KiB
C
Raw Normal View History

/*
+----------------------------------------------------------------------+
| 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
*/