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