HTP  0.3
htp_decompressors.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  * Copyright 2009-2010 Open Information Security Foundation
00003  * Copyright 2010-2011 Qualys, Inc.
00004  *
00005  * Licensed to You under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  ***************************************************************************/
00017 
00023 #ifndef _HTP_DECOMPRESSORS_H
00024 #define _HTP_DECOMPRESSORS_H
00025 
00026 typedef struct htp_decompressor_gzip_t htp_decompressor_gzip_t;
00027 typedef struct htp_decompressor_t htp_decompressor_t;
00028 
00029 #include "zlib.h"
00030 
00031 #define GZIP_BUF_SIZE       8192
00032 #define GZIP_WINDOW_SIZE    -15
00033 
00034 #define DEFLATE_MAGIC_1     0x1f
00035 #define DEFLATE_MAGIC_2     0x8b
00036 
00037 #define COMPRESSION_NONE        0
00038 #define COMPRESSION_GZIP        1
00039 #define COMPRESSION_DEFLATE     2
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 struct htp_decompressor_t {
00046     int (*decompress)(htp_decompressor_t *, htp_tx_data_t *);
00047     int (*callback)(htp_tx_data_t *);
00048     void (*destroy)(htp_decompressor_t *);
00049 };
00050 
00051 struct htp_decompressor_gzip_t {
00052     htp_decompressor_t super;
00053     int initialized;
00054     int zlib_initialized;
00055     uint8_t header[10];
00056     uint8_t header_len;
00057     z_stream stream;
00058     unsigned char *buffer;
00059     unsigned long crc;    
00060 };
00061 
00062 htp_decompressor_t * htp_gzip_decompressor_create(htp_connp_t *connp, int format);
00063 
00064 #ifdef __cplusplus
00065 }
00066 #endif
00067 
00068 #endif  /* _HTP_DECOMPRESSORS_H */
00069