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 
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_core.h"
49 
50 #include "bstr.h"
51 #include "htp_base64.h"
52 #include "htp_config.h"
53 #include "htp_connection_parser.h"
54 #include "htp_decompressors.h"
55 #include "htp_hooks.h"
56 #include "htp_list.h"
57 #include "htp_multipart.h"
58 #include "htp_table.h"
59 #include "htp_transaction.h"
60 #include "htp_urlencoded.h"
61 #include "htp_utf8_decoder.h"
62 
66 struct htp_conn_t {
68  char *client_addr;
69 
72 
74  char *server_addr;
75 
78 
85 
88 
90  uint8_t flags;
91 
94 
97 
99  int64_t in_data_counter;
100 
103 };
104 
110 struct htp_file_t {
113 
116 
118  int64_t len;
119 
121  char *tmpname;
122 
124  int fd;
125 };
126 
133 
135  const unsigned char *data;
136 
138  size_t len;
139 };
140 
144 struct htp_log_t {
147 
150 
152  const char *msg;
153 
156 
158  int code;
159 
161  const char *file;
162 
164  unsigned int line;
165 };
166 
170 struct htp_header_t {
173 
176 
178  uint64_t flags;
179 };
180 
184 struct htp_param_t {
187 
190 
193 
196 
201  void *parser_data;
202 };
203 
207 struct htp_tx_t {
210 
213 
216 
222 
224  void *user_data;
225 
226 
227  // Request fields
228 
230  unsigned int request_ignored_lines;
231 
234 
237 
240 
248 
251 
257 
265 
272 
280 
281  /* HTTP 1.1 RFC
282  *
283  * 4.3 Message Body
284  *
285  * The message-body (if any) of an HTTP message is used to carry the
286  * entity-body associated with the request or response. The message-body
287  * differs from the entity-body only when a transfer-coding has been
288  * applied, as indicated by the Transfer-Encoding header field (section
289  * 14.41).
290  *
291  * message-body = entity-body
292  * | <entity-body encoded as per Transfer-Encoding>
293  */
294 
304 
314 
317 
324 
327 
334 
342 
348 
354 
360 
366 
372 
375 
378 
381 
384 
387 
395 
401 
402 
403  // Response fields
404 
407 
410 
413 
419 
425 
431 
437 
440 
443 
446 
447  /* HTTP 1.1 RFC
448  *
449  * 4.3 Message Body
450  *
451  * The message-body (if any) of an HTTP message is used to carry the
452  * entity-body associated with the request or response. The message-body
453  * differs from the entity-body only when a transfer-coding has been
454  * applied, as indicated by the Transfer-Encoding header field (section
455  * 14.41).
456  *
457  * message-body = entity-body
458  * | <entity-body encoded as per Transfer-Encoding>
459  */
460 
470 
480 
488 
494 
501 
510 
517 
518 
519  // Common fields
520 
525  uint64_t flags;
526 
529 
532 };
533 
541 
543  const unsigned char *data;
544 
546  size_t len;
547 
553  int is_last;
554 };
555 
562 struct htp_uri_t {
565 
568 
571 
574 
577 
584 
587 
590 
595 };
596 
602 void htp_uri_free(htp_uri_t *uri);
603 
609 htp_uri_t *htp_uri_alloc(void);
610 
623 void htp_log(htp_connp_t *connp, const char *file, int line, enum htp_log_level_t level, int code, const char *fmt, ...);
624 
625 #ifdef __cplusplus
626 }
627 #endif
628 
629 #endif /* _HTP_H */