lsapidef.h 5.7 KB

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