HTP
0.3
|
00001 /*************************************************************************** 00002 * Copyright (c) 2009-2010, Open Information Security Foundation 00003 * Copyright (c) 2009-2012, Qualys, Inc. 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are 00008 * met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the Qualys, Inc. nor the names of its 00016 * contributors may be used to endorse or promote products derived from 00017 * this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00020 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00021 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00022 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00023 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00024 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00025 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00026 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00027 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00028 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00029 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 ***************************************************************************/ 00031 00037 #ifndef _HTP_DECOMPRESSORS_H 00038 #define _HTP_DECOMPRESSORS_H 00039 00040 typedef struct htp_decompressor_gzip_t htp_decompressor_gzip_t; 00041 typedef struct htp_decompressor_t htp_decompressor_t; 00042 00043 #include "zlib.h" 00044 00045 #define GZIP_BUF_SIZE 8192 00046 #define GZIP_WINDOW_SIZE -15 00047 00048 #define DEFLATE_MAGIC_1 0x1f 00049 #define DEFLATE_MAGIC_2 0x8b 00050 00051 #define COMPRESSION_NONE 0 00052 #define COMPRESSION_GZIP 1 00053 #define COMPRESSION_DEFLATE 2 00054 00055 #ifdef __cplusplus 00056 extern "C" { 00057 #endif 00058 00059 struct htp_decompressor_t { 00060 int (*decompress)(htp_decompressor_t *, htp_tx_data_t *); 00061 int (*callback)(htp_tx_data_t *); 00062 void (*destroy)(htp_decompressor_t *); 00063 }; 00064 00065 struct htp_decompressor_gzip_t { 00066 htp_decompressor_t super; 00067 int initialized; 00068 int zlib_initialized; 00069 uint8_t header[10]; 00070 uint8_t header_len; 00071 z_stream stream; 00072 unsigned char *buffer; 00073 unsigned long crc; 00074 }; 00075 00076 htp_decompressor_t * htp_gzip_decompressor_create(htp_connp_t *connp, int format); 00077 00078 #ifdef __cplusplus 00079 } 00080 #endif 00081 00082 #endif /* _HTP_DECOMPRESSORS_H */ 00083