HTP 0.5
htp.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
38
39#ifndef _HTP_H
40#define _HTP_H
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#include <sys/time.h>
47
48#include "htp_version.h"
49#include "htp_core.h"
50
51#include "bstr.h"
52#include "htp_base64.h"
53#include "htp_config.h"
55#include "htp_decompressors.h"
56#include "htp_hooks.h"
57#include "htp_list.h"
58#include "htp_multipart.h"
59#include "htp_table.h"
60#include "htp_transaction.h"
61#include "htp_urlencoded.h"
62#include "htp_utf8_decoder.h"
63
105
114
117
119 int64_t len;
120
122 char *tmpname;
123
125 int fd;
126};
127
134
136 const unsigned char *data;
137
139 size_t len;
140};
141
145struct htp_log_t {
148
151
153 const char *msg;
154
157
159 int code;
160
162 const char *file;
163
165 unsigned int line;
166};
167
174
177
179 uint64_t flags;
180};
181
204
208struct htp_tx_t {
211
214
217
223
224 SCAN_BUILD_X64_PADDING(int pad0;)
225
228
229
230 // Request fields
231
234
235 SCAN_BUILD_X64_PADDING(int pad1;)
236
239
242
245
246 SCAN_BUILD_X64_PADDING(int pad2;)
247
256
259
265
273
282
290
291 /* HTTP 1.1 RFC
292 *
293 * 4.3 Message Body
294 *
295 * The message-body (if any) of an HTTP message is used to carry the
296 * entity-body associated with the request or response. The message-body
297 * differs from the entity-body only when a transfer-coding has been
298 * applied, as indicated by the Transfer-Encoding header field (section
299 * 14.41).
300 *
301 * message-body = entity-body
302 * | <entity-body encoded as per Transfer-Encoding>
303 */
304
314
324
327
334
337
344
352
358
364
370
376
382
385
388
391
394
397
405
411
412
413 // Response fields
414
417
420
423
429
430 SCAN_BUILD_X64_PADDING(int pad3;)
431
437
443
449
452
455
456 SCAN_BUILD_X64_PADDING(int pad4;)
457
460
461 /* HTTP 1.1 RFC
462 *
463 * 4.3 Message Body
464 *
465 * The message-body (if any) of an HTTP message is used to carry the
466 * entity-body associated with the request or response. The message-body
467 * differs from the entity-body only when a transfer-coding has been
468 * applied, as indicated by the Transfer-Encoding header field (section
469 * 14.41).
470 *
471 * message-body = entity-body
472 * | <entity-body encoded as per Transfer-Encoding>
473 */
474
484
494
502
508
515
524
525 SCAN_BUILD_X64_PADDING(int pad5;)
526
533
534
535 // Common fields
536
541 uint64_t flags;
542
545
548
550 size_t index;
551
554
557};
558
566
568 const unsigned char *data;
569
571 size_t len;
572
579};
580
621
627void htp_uri_free(htp_uri_t *uri);
628
635
648void htp_log(htp_connp_t *connp, const char *file, int line, enum htp_log_level_t level, int code, const char *fmt, ...);
649
661htp_status_t htp_urldecode_inplace(htp_cfg_t *cfg, enum htp_decoder_ctx_t ctx, bstr *input, uint64_t *flags);
662
677htp_status_t htp_urldecode_inplace_ex(htp_cfg_t *cfg, enum htp_decoder_ctx_t ctx, bstr *input, uint64_t *flags, int *expected_status_code);
678
684char *htp_get_version(void);
685
686#ifdef __cplusplus
687}
688#endif
689
690#endif /* _HTP_H */
struct bstr_t bstr
Definition bstr.h:46
htp_status_t htp_urldecode_inplace(htp_cfg_t *cfg, enum htp_decoder_ctx_t ctx, bstr *input, uint64_t *flags)
Definition htp_util.c:1565
char * htp_get_version(void)
Definition htp_util.c:2543
void htp_log(htp_connp_t *connp, const char *file, int line, enum htp_log_level_t level, int code, const char *fmt,...)
Definition htp_util.c:411
htp_status_t htp_urldecode_inplace_ex(htp_cfg_t *cfg, enum htp_decoder_ctx_t ctx, bstr *input, uint64_t *flags, int *expected_status_code)
Definition htp_util.c:1570
htp_uri_t * htp_uri_alloc(void)
Definition htp_util.c:2534
void htp_uri_free(htp_uri_t *uri)
Definition htp_util.c:2519
htp_decoder_ctx_t
Definition htp_config.h:51
htp_auth_type_t
Definition htp_core.h:173
struct timeval htp_time_t
Definition htp_core.h:111
htp_data_source_t
Definition htp_core.h:372
htp_content_encoding_t
Definition htp_core.h:197
htp_method_t
Definition htp_core.h:317
#define SCAN_BUILD_X64_PADDING(_x)
Definition htp_core.h:94
htp_file_source_t
Definition htp_core.h:241
int htp_status_t
Definition htp_core.h:97
htp_parser_id_t
Definition htp_core.h:354
htp_transfer_coding_t
Definition htp_core.h:224
htp_log_level_t
Definition htp_core.h:304
#define htp_list_t
Definition htp_list.h:48
htp_tx_req_progress_t
Definition htp_transaction.h:75
htp_tx_res_progress_t
Definition htp_transaction.h:84
Definition htp_config_private.h:123
Definition htp.h:67
char * client_addr
Definition htp.h:69
int64_t in_data_counter
Definition htp.h:100
int64_t out_data_counter
Definition htp.h:103
char * server_addr
Definition htp.h:75
htp_time_t close_timestamp
Definition htp.h:97
int client_port
Definition htp.h:72
htp_time_t open_timestamp
Definition htp.h:94
uint8_t flags
Definition htp.h:91
htp_list_t * messages
Definition htp.h:88
htp_list_t * transactions
Definition htp.h:85
int server_port
Definition htp.h:78
Definition htp_connection_parser_private.h:51
Definition htp.h:131
size_t len
Definition htp.h:139
htp_file_t * file
Definition htp.h:133
const unsigned char * data
Definition htp.h:136
Definition htp.h:111
char * tmpname
Definition htp.h:122
int64_t len
Definition htp.h:119
bstr * filename
Definition htp.h:116
enum htp_file_source_t source
Definition htp.h:113
int fd
Definition htp.h:125
Definition htp.h:171
uint64_t flags
Definition htp.h:179
bstr * value
Definition htp.h:176
bstr * name
Definition htp.h:173
Definition htp_hooks.h:52
Definition htp.h:145
htp_tx_t * tx
Definition htp.h:150
enum htp_log_level_t level
Definition htp.h:156
htp_connp_t * connp
Definition htp.h:147
const char * msg
Definition htp.h:153
int code
Definition htp.h:159
unsigned int line
Definition htp.h:165
const char * file
Definition htp.h:162
Definition htp_multipart_private.h:85
Definition htp.h:185
bstr * value
Definition htp.h:190
void * parser_data
Definition htp.h:202
enum htp_data_source_t source
Definition htp.h:193
enum htp_parser_id_t parser_id
Definition htp.h:196
bstr * name
Definition htp.h:187
Definition htp_table_private.h:63
Definition htp.h:563
size_t len
Definition htp.h:571
htp_tx_t * tx
Definition htp.h:565
const unsigned char * data
Definition htp.h:568
int is_last
Definition htp.h:578
Definition htp.h:208
bstr * response_line
Definition htp.h:419
int64_t request_entity_len
Definition htp.h:323
bstr * response_content_type
Definition htp.h:532
int is_config_shared
Definition htp.h:222
int response_status_number
Definition htp.h:442
bstr * response_message
Definition htp.h:451
int request_protocol_number
Definition htp.h:264
enum htp_transfer_coding_t response_transfer_coding
Definition htp.h:507
enum htp_transfer_coding_t request_transfer_coding
Definition htp.h:333
bstr * request_line
Definition htp.h:238
bstr * response_protocol
Definition htp.h:422
int64_t response_content_length
Definition htp.h:501
bstr * request_content_type
Definition htp.h:343
bstr * request_method
Definition htp.h:241
bstr * request_auth_username
Definition htp.h:393
htp_conn_t * conn
Definition htp.h:213
bstr * request_hostname
Definition htp.h:404
htp_urlenp_t * request_urlenp_query
Definition htp.h:369
htp_urlenp_t * request_urlenp_body
Definition htp.h:375
enum htp_content_encoding_t response_content_encoding
Definition htp.h:514
uint64_t flags
Definition htp.h:541
htp_uri_t * parsed_uri
Definition htp.h:281
bstr * response_status
Definition htp.h:436
int is_protocol_0_9
Definition htp.h:272
enum htp_content_encoding_t response_content_encoding_processing
Definition htp.h:523
int64_t request_content_length
Definition htp.h:351
uint16_t req_header_repetitions
Definition htp.h:553
bstr * request_protocol
Definition htp.h:258
unsigned int response_ignored_lines
Definition htp.h:416
int64_t response_message_len
Definition htp.h:483
uint16_t res_header_repetitions
Definition htp.h:556
int response_status_expected_number
Definition htp.h:448
htp_cfg_t * cfg
Definition htp.h:216
int64_t response_entity_len
Definition htp.h:493
enum htp_content_encoding_t request_content_encoding
Definition htp.h:336
htp_connp_t * connp
Definition htp.h:210
int seen_100continue
Definition htp.h:454
enum htp_method_t request_method_number
Definition htp.h:244
enum htp_tx_req_progress_t request_progress
Definition htp.h:544
int64_t request_message_len
Definition htp.h:313
enum htp_tx_res_progress_t response_progress
Definition htp.h:547
int response_protocol_number
Definition htp.h:428
htp_table_t * response_headers
Definition htp.h:459
htp_table_t * request_cookies
Definition htp.h:387
unsigned int request_ignored_lines
Definition htp.h:233
htp_table_t * request_params
Definition htp.h:384
void * user_data
Definition htp.h:227
htp_table_t * request_headers
Definition htp.h:326
bstr * request_auth_password
Definition htp.h:396
htp_mpartp_t * request_mpartp
Definition htp.h:381
htp_hook_t * hook_response_body_data
Definition htp.h:363
enum htp_auth_type_t request_auth_type
Definition htp.h:390
size_t index
Definition htp.h:550
int request_port_number
Definition htp.h:410
htp_uri_t * parsed_uri_raw
Definition htp.h:289
htp_hook_t * hook_request_body_data
Definition htp.h:357
bstr * request_uri
Definition htp.h:255
Definition htp.h:587
bstr * path
Definition htp.h:611
bstr * fragment
Definition htp.h:619
int port_number
Definition htp.h:608
bstr * port
Definition htp.h:601
bstr * scheme
Definition htp.h:589
bstr * password
Definition htp.h:595
bstr * query
Definition htp.h:614
bstr * username
Definition htp.h:592
bstr * hostname
Definition htp.h:598
Definition htp_urlencoded.h:63