00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef HTP_TRANSACTION_H
00040 #define HTP_TRANSACTION_H
00041
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045
00046 #include "htp.h"
00047
00053 enum htp_alloc_strategy_t {
00059 HTP_ALLOC_COPY = 1,
00060
00066 HTP_ALLOC_REUSE = 2
00067 };
00068
00075 enum htp_tx_req_progress_t {
00076 HTP_REQUEST_NOT_STARTED = 0,
00077 HTP_REQUEST_LINE = 1,
00078 HTP_REQUEST_HEADERS = 2,
00079 HTP_REQUEST_BODY = 3,
00080 HTP_REQUEST_TRAILER = 4,
00081 HTP_REQUEST_COMPLETE = 5
00082 };
00083
00084 enum htp_tx_res_progress_t {
00085 HTP_RESPONSE_NOT_STARTED = 0,
00086 HTP_RESPONSE_LINE = 1,
00087 HTP_RESPONSE_HEADERS = 2,
00088 HTP_RESPONSE_BODY = 3,
00089 HTP_RESPONSE_TRAILER = 4,
00090 HTP_RESPONSE_COMPLETE = 5
00091 };
00092
00093 #define HTP_CONFIG_PRIVATE 0
00094 #define HTP_CONFIG_SHARED 1
00095
00102 htp_tx_t *htp_tx_create(htp_connp_t *connp);
00103
00109 htp_status_t htp_tx_destroy(htp_tx_t *tx);
00110
00119 int htp_tx_get_is_config_shared(const htp_tx_t *tx);
00120
00127 void *htp_tx_get_user_data(const htp_tx_t *tx);
00128
00135 void htp_tx_register_request_body_data(htp_tx_t *tx, int (*callback_fn)(htp_tx_data_t *));
00136
00143 void htp_tx_register_response_body_data(htp_tx_t *tx, int (*callback_fn)(htp_tx_data_t *));
00144
00153 htp_status_t htp_tx_req_add_param(htp_tx_t *tx, htp_param_t *param);
00154
00163 htp_param_t *htp_tx_req_get_param(htp_tx_t *tx, const char *name, size_t name_len);
00164
00175 htp_param_t *htp_tx_req_get_param_ex(htp_tx_t *tx, enum htp_data_source_t source, const char *name, size_t name_len);
00176
00183 int htp_tx_req_has_body(const htp_tx_t *tx);
00184
00199 htp_status_t htp_tx_req_process_body_data(htp_tx_t *tx, const void *data, size_t len);
00200
00214 htp_status_t htp_tx_req_set_header(htp_tx_t *tx, const char *name, size_t name_len,
00215 const char *value, size_t value_len, enum htp_alloc_strategy_t alloc);
00216
00229 htp_status_t htp_tx_req_set_headers_clear(htp_tx_t *tx);
00230
00241 htp_status_t htp_tx_req_set_line(htp_tx_t *tx, const char *line, size_t line_len, enum htp_alloc_strategy_t alloc);
00242
00253 htp_status_t htp_tx_req_set_method(htp_tx_t *tx, const char *method, size_t method_len, enum htp_alloc_strategy_t alloc);
00254
00264 void htp_tx_req_set_method_number(htp_tx_t *tx, enum htp_method_t method_number);
00265
00276 void htp_tx_req_set_parsed_uri(htp_tx_t *tx, htp_uri_t *parsed_uri);
00277
00286 void htp_tx_req_set_protocol_0_9(htp_tx_t *tx, int is_protocol_0_9);
00287
00299 htp_status_t htp_tx_req_set_protocol(htp_tx_t *tx, const char *protocol, size_t protocol_len, enum htp_alloc_strategy_t alloc);
00300
00316 void htp_tx_req_set_protocol_number(htp_tx_t *tx, int protocol_number);
00317
00329 htp_status_t htp_tx_req_set_uri(htp_tx_t *tx, const char *uri, size_t uri_len, enum htp_alloc_strategy_t alloc);
00330
00349 htp_status_t htp_tx_res_process_body_data(htp_tx_t *tx, const void *data, size_t len);
00350
00364 htp_status_t htp_tx_res_set_header(htp_tx_t *tx, const char *name, size_t name_len,
00365 const char *value, size_t value_len, enum htp_alloc_strategy_t alloc);
00366
00379 htp_status_t htp_tx_res_set_headers_clear(htp_tx_t *tx);
00380
00389 void htp_tx_res_set_protocol_number(htp_tx_t *tx, int protocol_number);
00390
00402 htp_status_t htp_tx_res_set_status_line(htp_tx_t *tx, const char *line, size_t line_len, enum htp_alloc_strategy_t alloc);
00403
00411 void htp_tx_res_set_status_code(htp_tx_t *tx, int status_code);
00412
00423 htp_status_t htp_tx_res_set_status_message(htp_tx_t *tx, const char *msg, size_t msg_len, enum htp_alloc_strategy_t alloc);
00424
00440 void htp_tx_set_config(htp_tx_t *tx, htp_cfg_t *cfg, int is_cfg_shared);
00441
00448 void htp_tx_set_user_data(htp_tx_t *tx, void *user_data);
00449
00457 htp_status_t htp_tx_state_request_complete(htp_tx_t *tx);
00458
00467 htp_status_t htp_tx_state_request_headers(htp_tx_t *tx);
00468
00477 htp_status_t htp_tx_state_request_line(htp_tx_t *tx);
00478
00487 htp_status_t htp_tx_state_request_start(htp_tx_t *tx);
00488
00496 htp_status_t htp_tx_state_response_complete(htp_tx_t *tx);
00497
00505 htp_status_t htp_tx_state_response_headers(htp_tx_t *tx);
00506
00514 htp_status_t htp_tx_state_response_line(htp_tx_t *tx);
00515
00523 htp_status_t htp_tx_state_response_start(htp_tx_t *tx);
00524
00525 #ifdef __cplusplus
00526 }
00527 #endif
00528
00529 #endif