lsapidef.h 5.5 KB

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