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;
52 typedef struct htp_file_data_t htp_file_data_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;
57 typedef struct htp_tx_data_t htp_tx_data_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 // Below are all htp_status_t return codes used by LibHTP. Enum is not
63 // used here to allow applications to define their own codes.
64 
68 #define HTP_ERROR_RESERVED -1000
69 
71 #define HTP_ERROR -1
72 
78 #define HTP_DECLINED 0
79 
81 #define HTP_OK 1
82 
87 #define HTP_DATA 2
88 
99 #define HTP_DATA_OTHER 3
100 
106 #define HTP_STOP 4
107 
112 #define HTP_DATA_BUFFER 5
113 
117 #define HTP_STATUS_RESERVED 1000
118 
129 
132 
135 
138 
141 };
142 
150 
153 
156 
159 
162 };
163 
170 
173 
176 
179 
182 };
183 
185 
187 
188  HTP_FILE_PUT = 2
189 };
190 
191 // Various flag bits. Even though we have a flag field in several places
192 // (header, transaction, connection), these fields are all in the same namespace
193 // because we may want to set the same flag in several locations. For example, we
194 // may set HTP_FIELD_FOLDED on the actual folded header, but also on the transaction
195 // that contains the header. Both uses are useful.
196 
197 // Connection flags are 8 bits wide.
198 #define HTP_CONN_PIPELINED 0x000000001ULL
199 #define HTP_CONN_HTTP_0_9_EXTRA 0x000000002ULL
200 
201 // All other flags are 64 bits wide.
202 #define HTP_FIELD_UNPARSEABLE 0x000000004ULL
203 #define HTP_FIELD_INVALID 0x000000008ULL
204 #define HTP_FIELD_FOLDED 0x000000010ULL
205 #define HTP_FIELD_REPEATED 0x000000020ULL
206 #define HTP_FIELD_LONG 0x000000040ULL
207 #define HTP_FIELD_RAW_NUL 0x000000080ULL
208 #define HTP_REQUEST_SMUGGLING 0x000000100ULL
209 #define HTP_INVALID_FOLDING 0x000000200ULL
210 #define HTP_REQUEST_INVALID_T_E 0x000000400ULL
211 #define HTP_MULTI_PACKET_HEAD 0x000000800ULL
212 #define HTP_HOST_MISSING 0x000001000ULL
213 #define HTP_HOST_AMBIGUOUS 0x000002000ULL
214 #define HTP_PATH_ENCODED_NUL 0x000004000ULL
215 #define HTP_PATH_RAW_NUL 0x000008000ULL
216 #define HTP_PATH_INVALID_ENCODING 0x000010000ULL
217 #define HTP_PATH_INVALID 0x000020000ULL
218 #define HTP_PATH_OVERLONG_U 0x000040000ULL
219 #define HTP_PATH_ENCODED_SEPARATOR 0x000080000ULL
220 #define HTP_PATH_UTF8_VALID 0x000100000ULL /* At least one valid UTF-8 character and no invalid ones. */
221 #define HTP_PATH_UTF8_INVALID 0x000200000ULL
222 #define HTP_PATH_UTF8_OVERLONG 0x000400000ULL
223 #define HTP_PATH_HALF_FULL_RANGE 0x000800000ULL /* Range U+FF00 - U+FFEF detected. */
224 #define HTP_STATUS_LINE_INVALID 0x001000000ULL
225 #define HTP_HOSTU_INVALID 0x002000000ULL /* Host in the URI. */
226 #define HTP_HOSTH_INVALID 0x004000000ULL /* Host in the Host header. */
227 #define HTP_URLEN_ENCODED_NUL 0x008000000ULL
228 #define HTP_URLEN_INVALID_ENCODING 0x010000000ULL
229 #define HTP_URLEN_OVERLONG_U 0x020000000ULL
230 #define HTP_URLEN_HALF_FULL_RANGE 0x040000000ULL /* Range U+FF00 - U+FFEF detected. */
231 #define HTP_URLEN_RAW_NUL 0x080000000ULL
232 #define HTP_REQUEST_INVALID 0x100000000ULL
233 #define HTP_REQUEST_INVALID_C_L 0x200000000ULL
234 #define HTP_AUTH_INVALID 0x400000000ULL
235 
236 #define HTP_MAX_HEADERS_REPETITIONS 64
237 
238 #define HTP_HOST_INVALID ( HTP_HOSTU_INVALID | HTP_HOSTH_INVALID )
239 
240 // Logging-related constants.
241 #define HTP_LOG_MARK __FILE__,__LINE__
242 
253  HTP_LOG_DEBUG2 = 6
254 };
255 
292  HTP_M_INVALID = 28
293 };
294 
295 // A collection of unique parser IDs.
299 
302 };
303 
304 // Protocol version constants; an enum cannot be
305 // used here because we allow any properly-formatted protocol
306 // version (e.g., 1.3), even those that do not actually exist.
307 #define HTP_PROTOCOL_INVALID -2
308 #define HTP_PROTOCOL_UNKNOWN -1
309 #define HTP_PROTOCOL_0_9 9
310 #define HTP_PROTOCOL_1_0 100
311 #define HTP_PROTOCOL_1_1 101
312 
313 // A collection of possible data sources.
317 
320 
323 
325  HTP_SOURCE_BODY = 3
326 };
327 
328 #define HTP_STATUS_INVALID -1
329 #define HTP_STATUS_UNKNOWN 0
330 
343  HTP_STREAM_DATA = 9
344 };
345 
346 #ifdef __cplusplus
347 }
348 #endif
349 
350 #endif /* HTP_CORE_H */
htp_auth_type_t
Definition: htp_core.h:122
@ HTP_AUTH_DIGEST
Definition: htp_core.h:137
@ HTP_AUTH_UNRECOGNIZED
Definition: htp_core.h:140
@ HTP_AUTH_BASIC
Definition: htp_core.h:134
@ HTP_AUTH_NONE
Definition: htp_core.h:131
@ HTP_AUTH_UNKNOWN
Definition: htp_core.h:128
struct timeval htp_time_t
Definition: htp_core.h:60
htp_data_source_t
Definition: htp_core.h:314
@ HTP_SOURCE_QUERY_STRING
Definition: htp_core.h:319
@ HTP_SOURCE_URL
Definition: htp_core.h:316
@ HTP_SOURCE_BODY
Definition: htp_core.h:325
@ HTP_SOURCE_COOKIE
Definition: htp_core.h:322
htp_content_encoding_t
Definition: htp_core.h:143
@ HTP_COMPRESSION_DEFLATE
Definition: htp_core.h:158
@ HTP_COMPRESSION_LZMA
Definition: htp_core.h:161
@ HTP_COMPRESSION_GZIP
Definition: htp_core.h:155
@ HTP_COMPRESSION_NONE
Definition: htp_core.h:152
@ HTP_COMPRESSION_UNKNOWN
Definition: htp_core.h:149
htp_method_t
Definition: htp_core.h:259
@ HTP_M_GET
Definition: htp_core.h:266
@ HTP_M_COPY
Definition: htp_core.h:277
@ HTP_M_MKACTIVITY
Definition: htp_core.h:289
@ HTP_M_TRACE
Definition: htp_core.h:272
@ HTP_M_CHECKOUT
Definition: htp_core.h:282
@ HTP_M_CHECKIN
Definition: htp_core.h:284
@ HTP_M_HEAD
Definition: htp_core.h:265
@ HTP_M_CONNECT
Definition: htp_core.h:270
@ HTP_M_PROPFIND
Definition: htp_core.h:274
@ HTP_M_POST
Definition: htp_core.h:268
@ HTP_M_INVALID
Definition: htp_core.h:292
@ HTP_M_PUT
Definition: htp_core.h:267
@ HTP_M_REPORT
Definition: htp_core.h:287
@ HTP_M_OPTIONS
Definition: htp_core.h:271
@ HTP_M_UNCHECKOUT
Definition: htp_core.h:283
@ HTP_M_UNKNOWN
Definition: htp_core.h:264
@ HTP_M_LABEL
Definition: htp_core.h:286
@ HTP_M_PATCH
Definition: htp_core.h:273
@ HTP_M_BASELINE_CONTROL
Definition: htp_core.h:290
@ HTP_M_PROPPATCH
Definition: htp_core.h:275
@ HTP_M_UPDATE
Definition: htp_core.h:285
@ HTP_M_UNLOCK
Definition: htp_core.h:280
@ HTP_M_MKWORKSPACE
Definition: htp_core.h:288
@ HTP_M_MERGE
Definition: htp_core.h:291
@ HTP_M_MOVE
Definition: htp_core.h:278
@ HTP_M_MKCOL
Definition: htp_core.h:276
@ HTP_M_LOCK
Definition: htp_core.h:279
@ HTP_M_DELETE
Definition: htp_core.h:269
@ HTP_M_VERSION_CONTROL
Definition: htp_core.h:281
htp_file_source_t
Definition: htp_core.h:184
@ HTP_FILE_MULTIPART
Definition: htp_core.h:186
@ HTP_FILE_PUT
Definition: htp_core.h:188
struct htp_header_line_t htp_header_line_t
Definition: htp_core.h:54
int htp_status_t
Definition: htp_core.h:46
htp_parser_id_t
Definition: htp_core.h:296
@ HTP_PARSER_URLENCODED
Definition: htp_core.h:298
@ HTP_PARSER_MULTIPART
Definition: htp_core.h:301
htp_transfer_coding_t
Definition: htp_core.h:167
@ HTP_CODING_INVALID
Definition: htp_core.h:181
@ HTP_CODING_IDENTITY
Definition: htp_core.h:175
@ HTP_CODING_CHUNKED
Definition: htp_core.h:178
@ HTP_CODING_UNKNOWN
Definition: htp_core.h:169
@ HTP_CODING_NO_BODY
Definition: htp_core.h:172
htp_stream_state_t
Definition: htp_core.h:335
@ HTP_STREAM_CLOSED
Definition: htp_core.h:338
@ HTP_STREAM_TUNNEL
Definition: htp_core.h:340
@ HTP_STREAM_STOP
Definition: htp_core.h:342
@ HTP_STREAM_DATA_OTHER
Definition: htp_core.h:341
@ HTP_STREAM_OPEN
Definition: htp_core.h:337
@ HTP_STREAM_DATA
Definition: htp_core.h:343
@ HTP_STREAM_NEW
Definition: htp_core.h:336
@ HTP_STREAM_ERROR
Definition: htp_core.h:339
htp_log_level_t
Definition: htp_core.h:246
@ HTP_LOG_INFO
Definition: htp_core.h:251
@ HTP_LOG_NONE
Definition: htp_core.h:247
@ HTP_LOG_NOTICE
Definition: htp_core.h:250
@ HTP_LOG_DEBUG
Definition: htp_core.h:252
@ HTP_LOG_ERROR
Definition: htp_core.h:248
@ HTP_LOG_DEBUG2
Definition: htp_core.h:253
@ HTP_LOG_WARNING
Definition: htp_core.h:249
Definition: htp_config_private.h:123
Definition: htp.h:67
Definition: htp_connection_parser_private.h:51
Definition: htp.h:131
Definition: htp.h:111
Definition: htp.h:171
Definition: htp.h:145
Definition: htp.h:185
Definition: htp.h:551
Definition: htp.h:208
Definition: htp.h:575