Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.74 KB | None | 0 0
  1. index 431cc9a..3c8b304 100644
  2. --- a/proxy/api/ts/remap.h
  3. +++ b/proxy/api/ts/remap.h
  4. @@ -21,9 +21,6 @@
  5. limitations under the License.
  6. */
  7.  
  8. -/* ------------------------------------------------------------------------- */
  9. -/* - RemapAPI.h - */
  10. -/* ------------------------------------------------------------------------- */
  11. #ifndef H_REMAPAPI_H
  12. #define H_REMAPAPI_H
  13.  
  14. @@ -32,55 +29,16 @@ extern "C"
  15. {
  16. #endif /* __cplusplus */
  17.  
  18. -#define TSREMAP_VMAJOR 2 /* major version number */
  19. +#define TSREMAP_VMAJOR 3 /* major version number */
  20. #define TSREMAP_VMINOR 0 /* minor version number */
  21. #define TSREMAP_VERSION ((TSREMAP_VMAJOR << 16)|TSREMAP_VMINOR)
  22.  
  23. - typedef int tsremap_interface(int cmd, ...);
  24. -
  25. typedef struct _tsremap_api_info
  26. {
  27. unsigned long size; /* in: sizeof(struct _tsremap_api_info) */
  28. unsigned long tsremap_version; /* in: TS supported version ((major << 16) | minor) */
  29. - tsremap_interface *fp_tsremap_interface; /* in: TS interface function pointer */
  30. } TSRemapInterface;
  31.  
  32. - typedef TSRemapInterface TSREMAP_INTERFACE; /* This is deprecated. */
  33. -
  34. - typedef void *base_handle;
  35. - typedef base_handle ihandle; /* plugin instance handle (per unique remap rule) */
  36. - typedef base_handle rhandle; /* request handle */
  37. -
  38. -
  39. - /* Plugin initialization - called first.
  40. - Mandatory interface function.
  41. - Return: 0 - success
  42. - != 0 - error, errbuf can include error message from plugin
  43. - */
  44. - int tsremap_init(TSRemapInterface * api_info, char *errbuf, int errbuf_size);
  45. - typedef int _tsremap_init(TSRemapInterface * api_info, char *errbuf, int errbuf_size);
  46. -#define TSREMAP_FUNCNAME_INIT "tsremap_init"
  47. -
  48. -
  49. - /* Plugin shutdown
  50. - Optional function. */
  51. - int tsremap_done(void);
  52. - typedef int _tsremap_done(void);
  53. -#define TSREMAP_FUNCNAME_DONE "tsremap_done"
  54. -
  55. - /* Plugin new instance. Create new plugin processing entry for unique remap record.
  56. - First two arguments in argv vector are - fromURL and toURL from remap record.
  57. - Please keep in mind that fromURL and toURL will be converted to canonical view.
  58. - Return: != 0 - instance creation error
  59. - 0 - success
  60. - */
  61. - int tsremap_new_instance(int argc, char *argv[], ihandle * ih, char *errbuf, int errbuf_size);
  62. - typedef int _tsremap_new_instance(int argc, char *argv[], ihandle * ih, char *errbuf, int errbuf_size);
  63. -#define TSREMAP_FUNCNAME_NEW_INSTANCE "tsremap_new_instance"
  64. -
  65. - void tsremap_delete_instance(ihandle);
  66. - typedef void _tsremap_delete_instance(ihandle);
  67. -#define TSREMAP_FUNCNAME_DELETE_INSTANCE "tsremap_delete_instance"
  68.  
  69. #define TSREMAP_RRI_MAX_HOST_SIZE 256
  70. #define TSREMAP_RRI_MAX_PATH_SIZE (1024*2)
  71. @@ -89,52 +47,43 @@ extern "C"
  72. typedef struct _tm_remap_request_info
  73. {
  74. /* the following fields are read only */
  75. - unsigned long size; /* sizeof(TSRemapRequestInfo) */
  76. -
  77. int request_port; /* request port number */
  78. int remap_from_port; /* fromURL port number (from remap rule string) */
  79. int remap_to_port; /* toURL port number (from remap rule string) */
  80.  
  81. - const char *orig_url; /* request URL */
  82. + const char* orig_url; /* request URL */
  83. int orig_url_size; /* request URL size */
  84.  
  85. - const char *request_host; /* request host string (without '\0' at the end of the string) */
  86. + const char* request_host; /* request host string (without '\0' at the end of the string) */
  87. int request_host_size; /* request host string size */
  88.  
  89. - const char *remap_from_host; /* fromURL host (from remap rule string) */
  90. + const char* remap_from_host; /* fromURL host (from remap rule string) */
  91. int remap_from_host_size; /* fromURL host size */
  92.  
  93. - const char *remap_to_host; /* toURL host (from remap rule string) */
  94. + const char* remap_to_host; /* toURL host (from remap rule string) */
  95. int remap_to_host_size; /* toURL host size */
  96.  
  97. - const char *request_path; /* request path */
  98. + const char* request_path; /* request path */
  99. int request_path_size; /* request path size */
  100.  
  101. - const char *remap_from_path; /* fromURL path (from remap rule string) */
  102. + const char* remap_from_path; /* fromURL path (from remap rule string) */
  103. int remap_from_path_size; /* fromURL path size */
  104.  
  105. - const char *remap_to_path; /* toURL path (from remap rule string) */
  106. + const char* remap_to_path; /* toURL path (from remap rule string) */
  107. int remap_to_path_size; /* toURL path size */
  108.  
  109. - const char *request_cookie; /* request cookie string */
  110. - int request_cookie_size; /* request cookie string size */
  111. -
  112. - const char *request_query; /* request query string */
  113. + const char* request_query; /* request query string */
  114. int request_query_size; /* request query string size. A negative size means remove it completely. */
  115.  
  116. - const char *request_matrix; /* request matrix string */
  117. + const char* request_matrix; /* request matrix string */
  118. int request_matrix_size; /* request matrix string size. A negative size means remove it completely. */
  119.  
  120. - const char *from_scheme; /* The "from" scheme (e.g. HTTP) */
  121. + const char* from_scheme; /* The "from" scheme (e.g. HTTP) */
  122. int from_scheme_len; /* The len of the "from" scheme */
  123.  
  124. - const char *to_scheme; /* The "to" scheme (e.g. HTTP) */
  125. + const char* to_scheme; /* The "to" scheme (e.g. HTTP) */
  126. int to_scheme_len; /* The len of the "to" scheme */
  127.  
  128. - unsigned int client_ip; /* The client IP is an unsigned network (big-endian) 32-bit number. */
  129. - /* Each of the dotted components is a byte, so: */
  130. - /* 0x25364758 = 0x25.0x36.0x47.0x58 = 37.54.71.88 in decimal. */
  131. -
  132. /* plugin can change the following fields */
  133. char new_host[TSREMAP_RRI_MAX_HOST_SIZE]; /* new host string */
  134. int new_host_size; /* new host string size (if 0 - do not change request host) */
  135. @@ -153,25 +102,52 @@ extern "C"
  136. /* -1 (default) -> Don't modify scheme */
  137. } TSRemapRequestInfo;
  138.  
  139. +
  140. +
  141. + /* ----------------------------------------------------------------------------------
  142. + These are the entry points a plugin can implement. Note that TSRemapInit() and
  143. + TSRemapDoRemap() are both required.
  144. + ----------------------------------------------------------------------------------
  145. + */
  146. +
  147. + /* Plugin initialization - called first.
  148. + Mandatory interface function.
  149. + Return: == 0 - success
  150. + != 0 - error, errbuf can include error message from plugin
  151. + */
  152. + int TSRemapInit(TSRemapInterface* api_info, char* errbuf, int errbuf_size);
  153. +
  154. +
  155. /* Remap new request
  156. + Mandatory interface function.
  157. + Remap API plugin can/should use SDK API function calls inside this function!
  158. Return: != 0 - request was remapped, TS must look at new_... fields in TSRemapRequestInfo
  159. == 0 - request was not processed. TS must perform default remap
  160. - Note: rhandle == TSHttpTxn (see ts/ts.h for more details)
  161. - Remap API plugin can use InkAPI function calls inside tsremap_remap()
  162. */
  163. - int tsremap_remap(ihandle ih, rhandle rh, TSRemapRequestInfo * rri);
  164. - typedef int _tsremap_remap(ihandle ih, rhandle rh, TSRemapRequestInfo * rri);
  165. -#define TSREMAP_FUNCNAME_REMAP "tsremap_remap"
  166. + int TSRemapDoRemap(void* ih, TSHttpTxn rh, TSRemapRequestInfo* rri);
  167. +
  168. +
  169. + /* Plugin shutdown, called when plugin is unloaded.
  170. + Optional function. */
  171. + int TSRemapDone(void);
  172. +
  173. +
  174. + /* Plugin new instance. Create new plugin processing entry for unique remap record.
  175. + First two arguments in argv vector are - fromURL and toURL from remap record.
  176. + Please keep in mind that fromURL and toURL will be converted to canonical view.
  177. + Return: != 0 - instance creation error
  178. + == 0 - success
  179. + */
  180. + int TSRemapNewInstance(int argc, char* argv[], void** ih, char* errbuf, int errbuf_size);
  181. + void TSRemapDeleteInstance(void*);
  182. +
  183.  
  184. /* Check response code from Origin Server
  185. - Return: none
  186. - Note: rhandle == TSHttpTxn (see ts/ts.h for more details)
  187. os_response_type -> TSServerState
  188. Remap API plugin can use InkAPI function calls inside tsremap_remap()
  189. + Return: none
  190. */
  191. - void tsremap_os_response(ihandle ih, rhandle rh, int os_response_type);
  192. - typedef void _tsremap_os_response(ihandle ih, rhandle rh, int os_response_type);
  193. -#define TSREMAP_FUNCNAME_OS_RESPONSE "tsremap_os_response"
  194. + void TSRemapOSResponse(void* ih, TSHttpTxn rh, int os_response_type);
  195.  
  196. #ifdef __cplusplus
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement