HTP  0.5
htp_core.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_CORE_H
40 #define HTP_CORE_H
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 typedef int htp_status_t;
47 
48 typedef struct htp_cfg_t htp_cfg_t;
49 typedef struct htp_conn_t htp_conn_t;
50 typedef struct htp_connp_t htp_connp_t;
51 typedef struct htp_file_t htp_file_t;
53 typedef struct htp_header_t htp_header_t;
55 typedef struct htp_log_t htp_log_t;
56 typedef struct htp_param_t htp_param_t;
58 typedef struct htp_tx_t htp_tx_t;
59 typedef struct htp_uri_t htp_uri_t;
60 typedef struct timeval htp_time_t;
61 
62 // Free-form version string
63 #define HTP_VERSION_STRING "master"
64 
65 // In the form of x.y.z, with two positions for each component; for example, 400 means 0.4.0
66 #define HTP_VERSION_NUMBER 500
67 
68 // Below are all htp_status_t return codes used by LibHTP. Enum is not
69 // used here to allow applications to define their own codes.
70 
74 #define HTP_ERROR_RESERVED -1000
75 
77 #define HTP_ERROR -1
78 
84 #define HTP_DECLINED 0
85 
87 #define HTP_OK 1
88 
93 #define HTP_DATA 2
94 
105 #define HTP_DATA_OTHER 3
106 
112 #define HTP_STOP 4
113 
118 #define HTP_DATA_BUFFER 5
119 
123 #define HTP_STATUS_RESERVED 1000
124 
135 
138 
141 
144 
147 };
148 
156 
159 
162 
165 };
166 
173 
176 
179 
182 
185 };
186 
188 
190 
192 };
193 
194 // Various flag bits. Even though we have a flag field in several places
195 // (header, transaction, connection), these fields are all in the same namespace
196 // because we may want to set the same flag in several locations. For example, we
197 // may set HTP_FIELD_FOLDED on the actual folded header, but also on the transaction
198 // that contains the header. Both uses are useful.
199 
200 // Connection flags are 8 bits wide.
201 #define HTP_CONN_PIPELINED 0x00000001
202 #define HTP_CONN_HTTP_0_9_EXTRA 0x00000002
203 
204 // All other flags are 64 bits wide.
205 #define HTP_FIELD_UNPARSEABLE 0x00000004
206 #define HTP_FIELD_INVALID 0x00000008
207 #define HTP_FIELD_FOLDED 0x00000010
208 #define HTP_FIELD_REPEATED 0x00000020
209 #define HTP_FIELD_LONG 0x00000040
210 #define HTP_FIELD_RAW_NUL 0x00000080
211 #define HTP_REQUEST_SMUGGLING 0x00000100
212 #define HTP_INVALID_FOLDING 0x00000200
213 #define HTP_REQUEST_INVALID_T_E 0x00000400
214 #define HTP_MULTI_PACKET_HEAD 0x00000800
215 #define HTP_HOST_MISSING 0x00001000
216 #define HTP_HOST_AMBIGUOUS 0x00002000
217 #define HTP_PATH_ENCODED_NUL 0x00004000
218 #define HTP_PATH_INVALID_ENCODING 0x00008000
219 #define HTP_PATH_INVALID 0x00010000
220 #define HTP_PATH_OVERLONG_U 0x00020000
221 #define HTP_PATH_ENCODED_SEPARATOR 0x00040000
222 #define HTP_PATH_UTF8_VALID 0x00080000 /* At least one valid UTF-8 character and no invalid ones. */
223 #define HTP_PATH_UTF8_INVALID 0x00100000
224 #define HTP_PATH_UTF8_OVERLONG 0x00200000
225 #define HTP_PATH_HALF_FULL_RANGE 0x00400000 /* Range U+FF00 - U+FFEF detected. */
226 #define HTP_STATUS_LINE_INVALID 0x00800000
227 #define HTP_HOSTU_INVALID 0x01000000 /* Host in the URI. */
228 #define HTP_HOSTH_INVALID 0x02000000 /* Host in the Host header. */
229 #define HTP_URLEN_ENCODED_NUL 0x04000000
230 #define HTP_URLEN_INVALID_ENCODING 0x08000000
231 #define HTP_URLEN_OVERLONG_U 0x10000000
232 #define HTP_URLEN_HALF_FULL_RANGE 0x20000000 /* Range U+FF00 - U+FFEF detected. */
233 #define HTP_REQUEST_INVALID 0x40000000
234 #define HTP_REQUEST_INVALID_C_L 0x80000000
235 
236 #define HTP_HOST_INVALID ( HTP_HOSTU_INVALID | HTP_HOSTH_INVALID )
237 
238 // Logging-related constants.
239 #define HTP_LOG_MARK __FILE__,__LINE__
240 
251 };
252 
290 };
291 
292 // A collection of unique parser IDs.
296 
299 };
300 
301 // Protocol version constants; an enum cannot be
302 // used here because we allow any properly-formatted protocol
303 // version (e.g., 1.3), even those that do not actually exist.
304 #define HTP_PROTOCOL_INVALID -2
305 #define HTP_PROTOCOL_UNKNOWN -1
306 #define HTP_PROTOCOL_0_9 9
307 #define HTP_PROTOCOL_1_0 100
308 #define HTP_PROTOCOL_1_1 101
309 
310 // A collection of possible data sources.
314 
317 
320 
323 };
324 
325 #define HTP_STATUS_INVALID -1
326 #define HTP_STATUS_UNKNOWN 0
327 
341 };
342 
343 #ifdef __cplusplus
344 }
345 #endif
346 
347 #endif /* HTP_DEFINITIONS_H */