php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_stream_transport.h
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | Copyright (c) The PHP Group |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | https://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Author: Wez Furlong <wez@thebrainroom.com> |
14 +----------------------------------------------------------------------+
15*/
16
17#ifdef PHP_WIN32
18#include "config.w32.h"
19#include <Ws2tcpip.h>
20#endif
21
22#ifdef HAVE_SYS_SOCKET_H
23# include <sys/socket.h>
24#endif
25
26typedef php_stream *(php_stream_transport_factory_func)(const char *proto, size_t protolen,
27 const char *resourcename, size_t resourcenamelen,
28 const char *persistent_id, int options, int flags,
29 struct timeval *timeout,
32
35PHPAPI int php_stream_xport_unregister(const char *protocol);
36
37#define STREAM_XPORT_CLIENT 0
38#define STREAM_XPORT_SERVER 1
39
40#define STREAM_XPORT_CONNECT 2
41#define STREAM_XPORT_BIND 4
42#define STREAM_XPORT_LISTEN 8
43#define STREAM_XPORT_CONNECT_ASYNC 16
44
45/* Open a client or server socket connection */
47 int flags, const char *persistent_id,
48 struct timeval *timeout,
50 zend_string **error_string,
51 int *error_code
53
54#define php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode) \
55 _php_stream_xport_create(name, namelen, options, flags, persistent_id, timeout, context, estr, ecode STREAMS_CC)
56
57/* Bind the stream to a local address */
59 const char *name, size_t namelen,
60 zend_string **error_text
61 );
62
63/* Connect to a remote address */
65 const char *name, size_t namelen,
66 int asynchronous,
67 struct timeval *timeout,
68 zend_string **error_text,
69 int *error_code
70 );
71
72/* Prepare to listen */
74 int backlog,
75 zend_string **error_text
76 );
77
78/* Get the next client and their address as a string, or the underlying address
79 * structure. You must efree either of these if you request them */
81 zend_string **textaddr,
82 void **addr, socklen_t *addrlen,
83 struct timeval *timeout,
84 zend_string **error_text
85 );
86
87/* Get the name of either the socket or it's peer */
88PHPAPI int php_stream_xport_get_name(php_stream *stream, int want_peer,
89 zend_string **textaddr,
90 void **addr, socklen_t *addrlen
91 );
92
97
98/* Similar to recv() system call; read data from the stream, optionally
99 * peeking, optionally retrieving OOB data */
100PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t buflen,
101 int flags, void **addr, socklen_t *addrlen,
102 zend_string **textaddr);
103
104/* Similar to send() system call; send data to the stream, optionally
105 * sending it as OOB data */
106PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t buflen,
107 int flags, void *addr, socklen_t addrlen);
108
114
115/* Similar to shutdown() system call; shut down part of a full-duplex
116 * connection */
119
120
121/* Structure definition for the set_option interface that the above functions wrap */
122
160
161/* Because both client and server streams use the same mechanisms
162 for encryption we use the LSB to denote clients.
163*/
164typedef enum {
167 /* v23 no longer negotiates SSL2 or SSL3 */
168 STREAM_CRYPTO_METHOD_SSLv23_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1),
173 /* TLS equates to TLS_ANY as of PHP 7.2 */
174 STREAM_CRYPTO_METHOD_TLS_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
175 STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
176 STREAM_CRYPTO_METHOD_ANY_CLIENT = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
179 /* v23 no longer negotiates SSL2 or SSL3 */
180 STREAM_CRYPTO_METHOD_SSLv23_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
185 /* TLS equates to TLS_ANY as of PHP 7.2 */
186 STREAM_CRYPTO_METHOD_TLS_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
187 STREAM_CRYPTO_METHOD_TLS_ANY_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
188 STREAM_CRYPTO_METHOD_ANY_SERVER = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6))
190
191/* These functions provide crypto support on the underlying transport */
192
195PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate);
197
212
unsigned int socklen_t
Definition fastcgi.c:87
zend_ffi_ctype_name_buf buf
Definition ffi.c:4685
const php_stream_filter_factory * factory
Definition filters.c:1900
#define PHPAPI
Definition php.h:71
PHP_JSON_API size_t int options
Definition php_json.h:102
php_json_error_code error_code
Definition php_json.h:92
PHPAPI php_stream_transport_factory_func php_stream_generic_socket_factory
PHPAPI int php_stream_xport_connect(php_stream *stream, const char *name, size_t namelen, int asynchronous, struct timeval *timeout, zend_string **error_text, int *error_code)
Definition transports.c:229
struct _php_stream_xport_crypto_param php_stream_xport_crypto_param
PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate)
Definition transports.c:378
php_stream * php_stream_transport_factory_func(const char *proto, size_t protolen, const char *resourcename, size_t resourcenamelen, const char *persistent_id, int options, int flags, struct timeval *timeout, php_stream_context *context STREAMS_DC)
PHPAPI int php_stream_xport_listen(php_stream *stream, int backlog, zend_string **error_text)
Definition transports.c:265
PHPAPI int php_stream_xport_accept(php_stream *stream, php_stream **client, zend_string **textaddr, void **addr, socklen_t *addrlen, struct timeval *timeout, zend_string **error_text)
Definition transports.c:289
PHPAPI HashTable * php_stream_xport_get_hash(void)
Definition transports.c:23
php_stream_xport_crypt_method_t
@ STREAM_CRYPTO_METHOD_SSLv23_SERVER
@ STREAM_CRYPTO_METHOD_SSLv3_CLIENT
@ STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
@ STREAM_CRYPTO_METHOD_SSLv2_SERVER
@ STREAM_CRYPTO_METHOD_SSLv3_SERVER
@ STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT
@ STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
@ STREAM_CRYPTO_METHOD_ANY_SERVER
@ STREAM_CRYPTO_METHOD_TLS_SERVER
@ STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT
@ STREAM_CRYPTO_METHOD_TLSv1_3_SERVER
@ STREAM_CRYPTO_METHOD_ANY_CLIENT
@ STREAM_CRYPTO_METHOD_TLS_CLIENT
@ STREAM_CRYPTO_METHOD_TLSv1_1_SERVER
@ STREAM_CRYPTO_METHOD_TLSv1_0_SERVER
@ STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
@ STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
@ STREAM_CRYPTO_METHOD_SSLv23_CLIENT
@ STREAM_CRYPTO_METHOD_SSLv2_CLIENT
@ STREAM_CRYPTO_METHOD_TLS_ANY_SERVER
PHPAPI int php_stream_xport_shutdown(php_stream *stream, stream_shutdown_t how)
Definition transports.c:509
struct _php_stream_xport_param php_stream_xport_param
PHPAPI int php_stream_xport_register(const char *protocol, php_stream_transport_factory factory)
Definition transports.c:28
PHPAPI int php_stream_xport_get_name(php_stream *stream, int want_peer, zend_string **textaddr, void **addr, socklen_t *addrlen)
Definition transports.c:327
PHPAPI php_stream * _php_stream_xport_create(const char *name, size_t namelen, int options, int flags, const char *persistent_id, struct timeval *timeout, php_stream_context *context, zend_string **error_string, int *error_code STREAMS_DC)
Definition transports.c:52
PHPAPI int php_stream_xport_unregister(const char *protocol)
Definition transports.c:37
php_stream_transport_factory_func * php_stream_transport_factory
PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream)
Definition transports.c:357
PHPAPI int php_stream_xport_bind(php_stream *stream, const char *name, size_t namelen, zend_string **error_text)
Definition transports.c:201
php_stream_xport_send_recv_flags
@ STREAM_PEEK
@ STREAM_SHUT_RD
@ STREAM_SHUT_WR
@ STREAM_SHUT_RDWR
PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t buflen, int flags, void **addr, socklen_t *addrlen, zend_string **textaddr)
Definition transports.c:400
PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t buflen, int flags, void *addr, socklen_t addrlen)
Definition transports.c:469
struct _php_stream php_stream
Definition php_streams.h:96
struct _php_stream_context php_stream_context
Definition php_streams.h:98
#define STREAMS_DC
Definition php_streams.h:53
ptrdiff_t namelen
Definition session.c:1097
php_stream_xport_crypt_method_t method
Definition dce.c:49
struct _zend_string zend_string
#define END_EXTERN_C()
#define BEGIN_EXTERN_C()
struct _zend_array HashTable
Definition zend_types.h:386
zend_string * name