xref: /PHP-7.2/sapi/litespeed/lsapidef.h (revision af414375)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available at through the world-wide-web at the following url:        |
10    | http://www.php.net/license/3_01.txt.                                 |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Author: George Wang <gwang@litespeedtech.com>                        |
16    +----------------------------------------------------------------------+
17 */
18 
19 /*
20 Copyright (c) 2002-2015, Lite Speed Technologies Inc.
21 All rights reserved.
22 
23 Redistribution and use in source and binary forms, with or without
24 modification, are permitted provided that the following conditions are
25 met:
26 
27     * Redistributions of source code must retain the above copyright
28       notice, this list of conditions and the following disclaimer.
29     * Redistributions in binary form must reproduce the above
30       copyright notice, this list of conditions and the following
31       disclaimer in the documentation and/or other materials provided
32       with the distribution.
33     * Neither the name of the Lite Speed Technologies Inc nor the
34       names of its contributors may be used to endorse or promote
35       products derived from this software without specific prior
36       written permission.
37 
38 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
42 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
46 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
48 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 */
50 
51 
52 #ifndef  _LSAPIDEF_H_
53 #define  _LSAPIDEF_H_
54 
55 #include <inttypes.h>
56 
57 #if defined (c_plusplus) || defined (__cplusplus)
58 extern "C" {
59 #endif
60 
61 enum
62 {
63     H_ACCEPT = 0,
64     H_ACC_CHARSET,
65     H_ACC_ENCODING,
66     H_ACC_LANG,
67     H_AUTHORIZATION,
68     H_CONNECTION,
69     H_CONTENT_TYPE,
70     H_CONTENT_LENGTH,
71     H_COOKIE,
72     H_COOKIE2,
73     H_HOST,
74     H_PRAGMA,
75     H_REFERER,
76     H_USERAGENT,
77     H_CACHE_CTRL,
78     H_IF_MODIFIED_SINCE,
79     H_IF_MATCH,
80     H_IF_NO_MATCH,
81     H_IF_RANGE,
82     H_IF_UNMOD_SINCE,
83     H_KEEP_ALIVE,
84     H_RANGE,
85     H_X_FORWARDED_FOR,
86     H_VIA,
87     H_TRANSFER_ENCODING
88 
89 };
90 #define LSAPI_SOCK_FILENO           0
91 
92 #define LSAPI_VERSION_B0            'L'
93 #define LSAPI_VERSION_B1            'S'
94 
95 /* Values for m_flag in lsapi_packet_header */
96 #define LSAPI_ENDIAN_LITTLE         0
97 #define LSAPI_ENDIAN_BIG            1
98 #define LSAPI_ENDIAN_BIT            1
99 
100 #if defined(__i386__)||defined( __x86_64 )||defined( __x86_64__ )
101 #define LSAPI_ENDIAN                LSAPI_ENDIAN_LITTLE
102 #else
103 #define LSAPI_ENDIAN                LSAPI_ENDIAN_BIG
104 #endif
105 
106 /* Values for m_type in lsapi_packet_header */
107 #define LSAPI_BEGIN_REQUEST         1
108 #define LSAPI_ABORT_REQUEST         2
109 #define LSAPI_RESP_HEADER           3
110 #define LSAPI_RESP_STREAM           4
111 #define LSAPI_RESP_END              5
112 #define LSAPI_STDERR_STREAM         6
113 #define LSAPI_REQ_RECEIVED          7
114 #define LSAPI_CONN_CLOSE            8
115 #define LSAPI_INTERNAL_ERROR        9
116 
117 
118 #define LSAPI_MAX_HEADER_LEN        65535
119 #define LSAPI_MAX_DATA_PACKET_LEN   16384
120 
121 #define LSAPI_RESP_HTTP_HEADER_MAX  32768
122 #define LSAPI_PACKET_HEADER_LEN     8
123 
124 
125 struct lsapi_packet_header
126 {
127     char    m_versionB0;      /* LSAPI protocol version */
128     char    m_versionB1;
129     char    m_type;
130     char    m_flag;
131     union
132     {
133         int32_t m_iLen;       /* include this header */
134         char    m_bytes[4];
135     }m_packetLen;
136 };
137 
138 /*
139     LSAPI request header packet
140 
141     1. struct lsapi_req_header
142     2. struct lsapi_http_header_index
143     3. lsapi_header_offset * unknownHeaders
144     4. org http request header
145     5. request body if available
146 */
147 
148 struct lsapi_req_header
149 {
150     struct lsapi_packet_header m_pktHeader;
151 
152     int32_t m_httpHeaderLen;
153     int32_t m_reqBodyLen;
154     int32_t m_scriptFileOff;   /* path to the script file. */
155     int32_t m_scriptNameOff;   /* decrypted URI, without pathinfo, */
156     int32_t m_queryStringOff;  /* Query string inside env */
157     int32_t m_requestMethodOff;
158     int32_t m_cntUnknownHeaders;
159     int32_t m_cntEnv;
160     int32_t m_cntSpecialEnv;
161 } ;
162 
163 
164 struct lsapi_http_header_index
165 {
166     uint16_t m_headerLen[H_TRANSFER_ENCODING+1];
167     int32_t m_headerOff[H_TRANSFER_ENCODING+1];
168 } ;
169 
170 struct lsapi_header_offset
171 {
172     int32_t nameOff;
173     int32_t nameLen;
174     int32_t valueOff;
175     int32_t valueLen;
176 } ;
177 
178 struct lsapi_resp_info
179 {
180     int32_t m_cntHeaders;
181     int32_t m_status;
182 };
183 
184 struct lsapi_resp_header
185 {
186     struct  lsapi_packet_header  m_pktHeader;
187     struct  lsapi_resp_info      m_respInfo;
188 };
189 
190 #if defined (c_plusplus) || defined (__cplusplus)
191 }
192 #endif
193 
194 
195 #endif
196