HTP
0.5
Main Page
Data Structures
Files
File List
Globals
htp
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
39
#ifndef _HTP_H
40
#define _HTP_H
41
42
#ifdef __cplusplus
43
extern
"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
"
54
#include "
htp_connection_parser.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
67
struct
htp_conn_t
{
69
char
*
client_addr
;
70
72
int
client_port
;
73
75
char
*
server_addr
;
76
78
int
server_port
;
79
85
htp_list_t
*
transactions
;
86
88
htp_list_t
*
messages
;
89
91
uint8_t
flags
;
92
94
htp_time_t
open_timestamp
;
95
97
htp_time_t
close_timestamp
;
98
100
int64_t
in_data_counter
;
101
103
int64_t
out_data_counter
;
104
};
105
111
struct
htp_file_t
{
113
enum
htp_file_source_t
source
;
114
116
bstr
*
filename
;
117
119
int64_t
len
;
120
122
char
*
tmpname
;
123
125
int
fd
;
126
};
127
131
struct
htp_file_data_t
{
133
htp_file_t
*
file
;
134
136
const
unsigned
char
*
data
;
137
139
size_t
len
;
140
};
141
145
struct
htp_log_t
{
147
htp_connp_t
*
connp
;
148
150
htp_tx_t
*
tx
;
151
153
const
char
*
msg
;
154
156
enum
htp_log_level_t
level
;
157
159
int
code
;
160
162
const
char
*
file
;
163
165
unsigned
int
line
;
166
};
167
171
struct
htp_header_t
{
173
bstr
*
name
;
174
176
bstr
*
value
;
177
179
uint64_t
flags
;
180
};
181
185
struct
htp_param_t
{
187
bstr
*
name
;
188
190
bstr
*
value
;
191
193
enum
htp_data_source_t
source
;
194
196
enum
htp_parser_id_t
parser_id
;
197
202
void
*
parser_data
;
203
};
204
208
struct
htp_tx_t
{
210
htp_connp_t
*
connp
;
211
213
htp_conn_t
*
conn
;
214
216
htp_cfg_t
*
cfg
;
217
222
int
is_config_shared
;
223
225
void
*
user_data
;
226
227
228
// Request fields
229
231
unsigned
int
request_ignored_lines
;
232
234
bstr
*
request_line
;
235
237
bstr
*
request_method
;
238
240
enum
htp_method_t
request_method_number
;
241
249
bstr
*
request_uri
;
250
252
bstr
*
request_protocol
;
253
258
int
request_protocol_number
;
259
266
int
is_protocol_0_9
;
267
275
htp_uri_t
*
parsed_uri
;
276
283
htp_uri_t
*
parsed_uri_raw
;
284
285
/* HTTP 1.1 RFC
286
*
287
* 4.3 Message Body
288
*
289
* The message-body (if any) of an HTTP message is used to carry the
290
* entity-body associated with the request or response. The message-body
291
* differs from the entity-body only when a transfer-coding has been
292
* applied, as indicated by the Transfer-Encoding header field (section
293
* 14.41).
294
*
295
* message-body = entity-body
296
* | <entity-body encoded as per Transfer-Encoding>
297
*/
298
307
int64_t
request_message_len
;
308
317
int64_t
request_entity_len
;
318
320
htp_table_t
*
request_headers
;
321
327
enum
htp_transfer_coding_t
request_transfer_coding
;
328
330
enum
htp_content_encoding_t
request_content_encoding
;
331
337
bstr
*
request_content_type
;
338
345
int64_t
request_content_length
;
346
351
htp_hook_t
*
hook_request_body_data
;
352
357
htp_hook_t
*
hook_response_body_data
;
358
363
htp_urlenp_t
*
request_urlenp_query
;
364
369
htp_urlenp_t
*
request_urlenp_body
;
370
375
htp_mpartp_t
*
request_mpartp
;
376
378
htp_table_t
*
request_params
;
379
381
htp_table_t
*
request_cookies
;
382
384
enum
htp_auth_type_t
request_auth_type
;
385
387
bstr
*
request_auth_username
;
388
390
bstr
*
request_auth_password
;
391
398
bstr
*
request_hostname
;
399
404
int
request_port_number
;
405
406
407
// Response fields
408
410
unsigned
int
response_ignored_lines
;
411
413
bstr
*
response_line
;
414
416
bstr
*
response_protocol
;
417
422
int
response_protocol_number
;
423
428
bstr
*
response_status
;
429
434
int
response_status_number
;
435
440
int
response_status_expected_number
;
441
443
bstr
*
response_message
;
444
446
int
seen_100continue
;
447
449
htp_table_t
*
response_headers
;
450
451
/* HTTP 1.1 RFC
452
*
453
* 4.3 Message Body
454
*
455
* The message-body (if any) of an HTTP message is used to carry the
456
* entity-body associated with the request or response. The message-body
457
* differs from the entity-body only when a transfer-coding has been
458
* applied, as indicated by the Transfer-Encoding header field (section
459
* 14.41).
460
*
461
* message-body = entity-body
462
* | <entity-body encoded as per Transfer-Encoding>
463
*/
464
473
int64_t
response_message_len
;
474
483
int64_t
response_entity_len
;
484
491
int64_t
response_content_length
;
492
497
enum
htp_transfer_coding_t
response_transfer_coding
;
498
504
enum
htp_content_encoding_t
response_content_encoding
;
505
513
enum
htp_content_encoding_t
response_content_encoding_processing
;
514
520
bstr
*
response_content_type
;
521
522
523
// Common fields
524
529
uint64_t
flags
;
530
532
enum
htp_tx_req_progress_t
request_progress
;
533
535
enum
htp_tx_res_progress_t
response_progress
;
536
};
537
542
struct
htp_tx_data_t
{
544
htp_tx_t
*
tx
;
545
547
const
unsigned
char
*
data
;
548
550
size_t
len
;
551
557
int
is_last
;
558
};
559
566
struct
htp_uri_t
{
568
bstr
*
scheme
;
569
571
bstr
*
username
;
572
574
bstr
*
password
;
575
577
bstr
*
hostname
;
578
580
bstr
*
port
;
581
587
int
port_number
;
588
590
bstr
*
path
;
591
593
bstr
*
query
;
594
598
bstr
*
fragment
;
599
};
600
606
void
htp_uri_free
(
htp_uri_t
*uri);
607
613
htp_uri_t
*
htp_uri_alloc
(
void
);
614
627
void
htp_log
(
htp_connp_t
*connp,
const
char
*file,
int
line,
enum
htp_log_level_t
level,
int
code,
const
char
*fmt, ...);
628
640
htp_status_t
htp_urldecode_inplace
(
htp_cfg_t
*cfg,
enum
htp_decoder_ctx_t
ctx,
bstr
*input, uint64_t *flags);
641
656
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);
657
663
char
*
htp_get_version
(
void
);
664
665
#ifdef __cplusplus
666
}
667
#endif
668
669
#endif
/* _HTP_H */
Generated by
1.8.3.1