HTP  0.5
htp_transaction.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2009-2010 Open Information Security Foundation
3  * Copyright (c) 2010-2013 Qualys, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * - Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12 
13  * - Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16 
17  * - Neither the name of the Qualys, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  ***************************************************************************/
33 
34 /*
35  * @file
36  * @author Ivan Ristic <ivanr@webkreator.com>
37  */
38 
39 #ifndef HTP_TRANSACTION_H
40 #define HTP_TRANSACTION_H
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #include "htp.h"
47 
59  HTP_ALLOC_COPY = 1,
60 
66  HTP_ALLOC_REUSE = 2
67 };
68 
82 };
83 
91 };
92 
93 #define HTP_CONFIG_PRIVATE 0
94 #define HTP_CONFIG_SHARED 1
95 
103 
110 
120 
127 void *htp_tx_get_user_data(const htp_tx_t *tx);
128 
135 void htp_tx_register_request_body_data(htp_tx_t *tx, int (*callback_fn)(htp_tx_data_t *));
136 
143 void htp_tx_register_response_body_data(htp_tx_t *tx, int (*callback_fn)(htp_tx_data_t *));
144 
154 
163 htp_param_t *htp_tx_req_get_param(htp_tx_t *tx, const char *name, size_t name_len);
164 
175 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);
176 
183 int htp_tx_req_has_body(const htp_tx_t *tx);
184 
199 htp_status_t htp_tx_req_process_body_data(htp_tx_t *tx, const void *data, size_t len);
200 
214 htp_status_t htp_tx_req_set_header(htp_tx_t *tx, const char *name, size_t name_len,
215  const char *value, size_t value_len, enum htp_alloc_strategy_t alloc);
216 
230 
241 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);
242 
253 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);
254 
264 void htp_tx_req_set_method_number(htp_tx_t *tx, enum htp_method_t method_number);
265 
276 void htp_tx_req_set_parsed_uri(htp_tx_t *tx, htp_uri_t *parsed_uri);
277 
286 void htp_tx_req_set_protocol_0_9(htp_tx_t *tx, int is_protocol_0_9);
287 
299 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);
300 
316 void htp_tx_req_set_protocol_number(htp_tx_t *tx, int protocol_number);
317 
329 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);
330 
349 htp_status_t htp_tx_res_process_body_data(htp_tx_t *tx, const void *data, size_t len);
350 
364 htp_status_t htp_tx_res_set_header(htp_tx_t *tx, const char *name, size_t name_len,
365  const char *value, size_t value_len, enum htp_alloc_strategy_t alloc);
366 
380 
389 void htp_tx_res_set_protocol_number(htp_tx_t *tx, int protocol_number);
390 
402 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);
403 
411 void htp_tx_res_set_status_code(htp_tx_t *tx, int status_code);
412 
423 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);
424 
440 void htp_tx_set_config(htp_tx_t *tx, htp_cfg_t *cfg, int is_cfg_shared);
441 
448 void htp_tx_set_user_data(htp_tx_t *tx, void *user_data);
449 
458 
468 
478 
488 
497 
506 
515 
524 
525 #ifdef __cplusplus
526 }
527 #endif
528 
529 #endif /* HTP_HYBRID_H */
htp_method_t
htp_method_t
Definition: htp_core.h:259
htp_tx_state_response_line
htp_status_t htp_tx_state_response_line(htp_tx_t *tx)
Definition: htp_transaction.c:670
htp_tx_t
Definition: htp.h:208
htp_tx_state_request_start
htp_status_t htp_tx_state_request_start(htp_tx_t *tx)
Definition: htp_transaction.c:966
HTP_REQUEST_BODY
@ HTP_REQUEST_BODY
Definition: htp_transaction.h:79
htp_tx_res_process_body_data
htp_status_t htp_tx_res_process_body_data(htp_tx_t *tx, const void *data, size_t len)
Definition: htp_transaction.c:833
htp_tx_set_user_data
void htp_tx_set_user_data(htp_tx_t *tx, void *user_data)
Definition: htp_transaction.c:236
htp_tx_req_set_headers_clear
htp_status_t htp_tx_req_set_headers_clear(htp_tx_t *tx)
Definition: htp_transaction.c:596
htp_tx_set_config
void htp_tx_set_config(htp_tx_t *tx, htp_cfg_t *cfg, int is_cfg_shared)
Definition: htp_transaction.c:222
htp_tx_register_request_body_data
void htp_tx_register_request_body_data(htp_tx_t *tx, int(*callback_fn)(htp_tx_data_t *))
Definition: htp_transaction.c:1407
htp_tx_state_request_headers
htp_status_t htp_tx_state_request_headers(htp_tx_t *tx)
Definition: htp_transaction.c:980
htp_tx_req_set_method_number
void htp_tx_req_set_method_number(htp_tx_t *tx, enum htp_method_t method_number)
Definition: htp_transaction.c:320
htp_tx_req_set_protocol_0_9
void htp_tx_req_set_protocol_0_9(htp_tx_t *tx, int is_protocol_0_9)
Definition: htp_transaction.c:348
htp_tx_req_set_protocol_number
void htp_tx_req_set_protocol_number(htp_tx_t *tx, int protocol_number)
Definition: htp_transaction.c:343
htp_tx_res_set_protocol_number
void htp_tx_res_set_protocol_number(htp_tx_t *tx, int protocol_number)
Definition: htp_transaction.c:647
htp_tx_req_set_protocol
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)
Definition: htp_transaction.c:334
HTP_REQUEST_TRAILER
@ HTP_REQUEST_TRAILER
Definition: htp_transaction.h:80
htp_tx_req_set_parsed_uri
void htp_tx_req_set_parsed_uri(htp_tx_t *tx, htp_uri_t *parsed_uri)
Definition: htp_transaction.c:626
htp_tx_req_set_method
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)
Definition: htp_transaction.c:311
htp_tx_get_user_data
void * htp_tx_get_user_data(const htp_tx_t *tx)
Definition: htp_transaction.c:217
htp_tx_res_set_header
htp_status_t htp_tx_res_set_header(htp_tx_t *tx, const char *name, size_t name_len, const char *value, size_t value_len, enum htp_alloc_strategy_t alloc)
Definition: htp_transaction.c:709
htp_cfg_t
Definition: htp_config_private.h:123
htp_uri_t
Definition: htp.h:575
HTP_RESPONSE_HEADERS
@ HTP_RESPONSE_HEADERS
Definition: htp_transaction.h:87
htp_tx_req_set_line
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)
Definition: htp_transaction.c:615
htp.h
htp_param_t
Definition: htp.h:185
HTP_REQUEST_HEADERS
@ HTP_REQUEST_HEADERS
Definition: htp_transaction.h:78
htp_tx_req_process_body_data
htp_status_t htp_tx_req_process_body_data(htp_tx_t *tx, const void *data, size_t len)
Definition: htp_transaction.c:564
htp_tx_req_get_param_ex
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)
Definition: htp_transaction.c:256
htp_status_t
int htp_status_t
Definition: htp_core.h:46
HTP_RESPONSE_BODY
@ HTP_RESPONSE_BODY
Definition: htp_transaction.h:88
htp_alloc_strategy_t
htp_alloc_strategy_t
Definition: htp_transaction.h:53
htp_connp_t
Definition: htp_connection_parser_private.h:51
htp_tx_req_set_uri
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)
Definition: htp_transaction.c:325
htp_tx_state_response_start
htp_status_t htp_tx_state_response_start(htp_tx_t *tx)
Definition: htp_transaction.c:1369
htp_tx_res_set_status_code
void htp_tx_res_set_status_code(htp_tx_t *tx, int status_code)
Definition: htp_transaction.c:652
htp_tx_req_get_param
htp_param_t * htp_tx_req_get_param(htp_tx_t *tx, const char *name, size_t name_len)
Definition: htp_transaction.c:251
HTP_RESPONSE_COMPLETE
@ HTP_RESPONSE_COMPLETE
Definition: htp_transaction.h:90
htp_tx_res_set_headers_clear
htp_status_t htp_tx_res_set_headers_clear(htp_tx_t *tx)
Definition: htp_transaction.c:740
htp_tx_destroy
htp_status_t htp_tx_destroy(htp_tx_t *tx)
Definition: htp_transaction.c:108
htp_tx_res_progress_t
htp_tx_res_progress_t
Definition: htp_transaction.h:84
htp_tx_req_set_header
htp_status_t htp_tx_req_set_header(htp_tx_t *tx, const char *name, size_t name_len, const char *value, size_t value_len, enum htp_alloc_strategy_t alloc)
Definition: htp_transaction.c:281
htp_tx_create
htp_tx_t * htp_tx_create(htp_connp_t *connp)
Definition: htp_transaction.c:53
HTP_REQUEST_COMPLETE
@ HTP_REQUEST_COMPLETE
Definition: htp_transaction.h:81
htp_tx_res_set_status_message
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)
Definition: htp_transaction.c:657
htp_tx_state_response_headers
htp_status_t htp_tx_state_response_headers(htp_tx_t *tx)
Definition: htp_transaction.c:1208
HTP_ALLOC_REUSE
@ HTP_ALLOC_REUSE
Definition: htp_transaction.h:97
HTP_RESPONSE_LINE
@ HTP_RESPONSE_LINE
Definition: htp_transaction.h:86
htp_tx_state_response_complete
htp_status_t htp_tx_state_response_complete(htp_tx_t *tx)
Definition: htp_transaction.c:1070
htp_tx_req_add_param
htp_status_t htp_tx_req_add_param(htp_tx_t *tx, htp_param_t *param)
Definition: htp_transaction.c:241
htp_tx_res_set_status_line
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)
Definition: htp_transaction.c:636
htp_tx_register_response_body_data
void htp_tx_register_response_body_data(htp_tx_t *tx, int(*callback_fn)(htp_tx_data_t *))
Definition: htp_transaction.c:1418
HTP_REQUEST_LINE
@ HTP_REQUEST_LINE
Definition: htp_transaction.h:77
HTP_REQUEST_NOT_STARTED
@ HTP_REQUEST_NOT_STARTED
Definition: htp_transaction.h:76
htp_tx_get_is_config_shared
int htp_tx_get_is_config_shared(const htp_tx_t *tx)
Definition: htp_transaction.c:212
HTP_ALLOC_COPY
@ HTP_ALLOC_COPY
Definition: htp_transaction.h:90
htp_data_source_t
htp_data_source_t
Definition: htp_core.h:314
htp_tx_data_t
Definition: htp.h:551
htp_tx_state_request_complete
htp_status_t htp_tx_state_request_complete(htp_tx_t *tx)
Definition: htp_transaction.c:935
htp_tx_req_progress_t
htp_tx_req_progress_t
Definition: htp_transaction.h:75
HTP_RESPONSE_TRAILER
@ HTP_RESPONSE_TRAILER
Definition: htp_transaction.h:89
HTP_RESPONSE_NOT_STARTED
@ HTP_RESPONSE_NOT_STARTED
Definition: htp_transaction.h:85
htp_tx_state_request_line
htp_status_t htp_tx_state_request_line(htp_tx_t *tx)
Definition: htp_transaction.c:1020
htp_tx_req_has_body
int htp_tx_req_has_body(const htp_tx_t *tx)
Definition: htp_transaction.c:271